How to set event handler in React sub-component?

Posted by Rohit Kumar | Updated on

Want to set event handler in React sub-component? The problem is that you’re creating the item nodes using an anonymous function, and inside that this means the window. The fix is to add .bind(this) to the anonymous function.

Or create a copy of this and use that instead:


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.

Related Questions & Answers