Yes, it is good to use arrow functions in render methods. It is often the easiest way to pass parameters to callback functions. But you need to optimize the performance while using it.
1 2 3 4 5 6 7 8 | class Foo extends Component { handleClick() { console.log('Click happened'); } render() { return <button onClick={() => this.handleClick()}>Click Me</button>; } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.