Cache your React event listeners to improve performance.
6 min readSep 10, 2018
An under-appreciated concept in JavaScript is how objects and functions are references, and that directly impacts React performance. If you were to create two functions that are completely identical, they are still not equal. Try for yourself:
But check out the difference if you assign a variable to an already-existing function:
Objects work the same way.
If you have experience in other languages, you may be familiar with pointers. What is happening here is that each time you create an object, you are allocating…