Understanding event pooling
One challenge of wrapping native event instances is that it can cause performance issues. Every synthetic event wrapper that’s created will also need to be garbage collected at some point, which can be expensive in terms of CPU time.
When the garbage collector is running, none of your JavaScript code is able to run. This is why it’s important to be memory-efficient; frequent garbage collection means less CPU time for code that responds to user interactions.
For example, if your application only handles a few events, this wouldn’t matter much. But even by modest standards, applications respond to many events, even if the handlers don’t actually do anything with them. This is problematic if React constantly has to allocate new synthetic event instances.
React deals with this problem by allocating a synthetic instance pool. Whenever an event is triggered, it takes an instance from the pool and populates its...