score:0
Accepted answer
you are setting onclick to tbe result of a function, not tbe function itself.
replace
`<img classname="arrow" onclick={this.state.data.sort(this.sortdescending("recent"))} src="https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-arrow-down-b-128.png" />`
with
<img classname="arrow" onclick = {() => this.state.data.sort(this.sortdescending("recent"))} src="https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-arrow-down-b-128.png" />
react onclick events cannot be anything but a function, for future reference. (also, js refers to arrays sometimes as objects, which explains the error you're getting)
Source: stackoverflow.com
Related Query
- Sort array onClick and render the array in React
- Sort an array of objects in React and render them
- mapping an array of objects and changing the value with on onClick in React
- How do I sort an array of objects in react and render them?
- How do I iterate though an array of objects with keys and values in react and render them in the JSX( Both keys and Values)
- In React How can I fetch data and render a single object in a states array without mapping the whole thing?
- Sort the array of objects in react on the basis of time and created date
- Filter array onClick and render the remaining items from the array
- React doesn't render array value from firebase and array's length is 0 despite having the value on console
- React JS - Can't maintain and render the state values after onclick
- How to update React properties after a delay in time and constantly sort an array to the nearest specific number X?
- how can i loop through the array inside of an object. and render it in the react component
- Array of objects does not render fully in React and shows the array length on console that does not match with the reality
- How to take items from an array that is in a React component's props and render to the page?
- React - Loop through an array of objects, and highlight the selected item onClick
- How to fetch an array of objects and render it in the component as a normal text using React Hooks?
- React Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `App`
- Invariant Violation in React Render OR the proper way to iterate and return in React
- Can I guarantee the render order of an array of React components?
- Why is my React checkbox onChange handler firing on render and then not when the box is clicked?
- React Router V4: How to render a modal in the same screen changing only the url and then with that url, be able to rebuild the whole screen
- Is there a clean way to conditionally load and render different components for the same React Router route?
- React hooks useState/setState not working after sorting the array and passing it
- react props undefined inside the constructor and exist inside the render
- How to filter and sort the same array of object state in redux?
- How to Separate Jsx inside render function into a separate file in ES6? or any other solution in react to separate the Logic and presentation?
- React render array of strings and JSX
- React Hook useEffect has missing dependencies: 'colors' and 'options'. Either include them or remove the dependency array
- React - How to correctly render the progress of array of promise?
- Handling onClick and onKeyPressDown in the same function React
More Query from same tag
- TypeScript type of an async dispatch value
- React Redux - Trouble trying to use React-DnD and mapDispatchToProps
- Not showing image upload field in react
- React class component issue in order of execution
- Exporting functions with reactjs and babel
- How to update passportJWT data after edit user data?
- React material-ui and reactstrap form inline with button new line
- How to access current element on event in react?
- Change color of label in material-ui
- Can an action that updates the store be dispatched on componentDidUpdate()?
- Safari on iOS randomly duplicates button style from the next button
- Executing a state method from the stateless component
- change route during axios causes memory leak in useEffect Hooks
- Transparency to Opacity conversion
- RadioGroup not passing the accurate value to the parent state
- Iphone automatically zooms in on <select> tag
- Updating the state of object of key:value (array) in React
- How can I test styled components?
- How can I align my labels, input, and textarea on same line?
- How to get contacts from phone using react native expo
- How do I POST form data using Fetch and React?
- redux pre-binding through bindActionCreators, an anti-pattern?
- create and open a pdf on a click of link and show print button with react-pdf
- Add new tab in Storybook story
- Added Element in an observabel array is not observable + ReactJs
- TextField doesn't render when fullWidth is true
- How to dispatch an action to change the inner state in a react component
- Push elements to the sides Antd (align one to the left and one to the right)
- Unit test does not pass when error is thrown
- Loading local JSON file in React for dynamic content