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)


Related Query

More Query from same tag