[WIP] Handling Events Flashcards

1
Q

What are the 2 main syntactic differences between handling events with React elements compared to handling events on DOM elements?

A
  1. React events are named using camelCase, rather than lowercase.
  2. With JSX you pass a function as the event handler, rather than a string.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When handling events in React can you return false false to prevent default behavior?

A

No. You must call preventDefault explicitly.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

True/False: In JavaScript, class methods are bound by default.

A

False. If you forget to bind your click handler and pass it to a click event, it will be undefined when the function is actually called.

The attached image shows the correct way to bind in the class constructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Methods can be bound to event handlers using arrow functions as illustrated in the image. However, this is problematic. Why?

A

The problem with this syntax is that a different callback is created each time the LoggingButton renders.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly