- What makes event handlers in React declarative?
- Any event handler function is declarative
- React event handlers are declared as part of the component JSX
- React event handlers aren't declarative
- What's a common use of higher-order event handler functions?
- When you have several components that handle the same event, you can use a higher-order function to bind the ID of the item being clicked to the handler function
- Higher-order functions should be used wherever possible as React event handler functions
- When you're not sure what data you'll need in the event handler, higher-order functions allow you to pass whatever you need
- Can you pass inline functions to event properties?
- Yes. This is preferable when event handlers are simple one-liners.
- No. You should always declare event handler functions as methods or bound functions.
- Why does React use pools of event instances instead of creating new instances with each event?
- React doesn't use event pools
- Because if it didn't, you would run out of memory eventually because these objects are never deleted
- To avoid invoking the garbage collector to delete unused event instances when lots of events are fired in a small amount of time