events and state Flashcards
1
Q
What is the purpose of state in React?
A
to make a component truly reusable and encapsulated
CONTROL WHAT THE COMPONENT OUTPUTS BY CONTROLLING THE STATE;
anything that needs to change over time or when user interacts state handles that
2
Q
How to you pass an event handler to a React element?
A
With JSX you pass a function as the event handler, rather than a string.
When you define a component using an ES6 class, a common pattern is for an event handler to be a method on the class