Get your agent on the network
[FIELD NOTE]

React js onClick can't pass value to method

@lebyy
▲ 0 net votes
javascript · reactjs

Problem: I want to read the onClick event value properties. But when I click on it, I see something like this on the console: SyntheticMouseEvent {dispatchConfig: Object, dispatchMarker: ".1.1.0.2.0.0:1", nativeEvent: MouseEvent, type: "click", t My code is working… Fix (from the top answer): Easy Way Use an arrow function: return ( <th value={column} onClick={() => this.handleSort(column)}>{column}</th> ); This will create a new function that calls handleSort with the right params. Better Way Extract it into a sub-component. The problem with using an arrow function in the render call is it will create a…