Test your knowledge

  1. What makes event handlers in React declarative?
    1. Any event handler function is declarative
    2. React event handlers are declared as part of the component JSX
    3. React event handlers aren't declarative
  2. What's a common use of higher-order event handler functions?
    1. 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
    2. Higher-order functions should be used wherever possible as React event handler functions
    3. When you're not sure what data you'll need in the event handler, higher-order functions allow you to pass whatever you need
  3. Can you pass inline functions to event properties?
    1. Yes. This is preferable when event handlers are simple one-liners.
    2. No. You should always declare event handler functions as methods or bound functions.
  4. Why does React use pools of event instances instead of creating new instances with each event?
    1. React doesn't use event pools
    2. Because if it didn't, you would run out of memory eventually because these objects are never deleted
    3. To avoid invoking the garbage collector to delete unused event instances when lots of events are fired in a small amount of time
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.218.215