react-events-and-state Flashcards

1
Q

What is the purpose of state in React?

A

The state is a built-in React object that is used to contain data or information about the component. A component’s state can change over time; whenever it changes, the component re-renders.

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

How to you pass an event handler to a React element?

A

Pass event handlers and other functions as props to child components:

< button onClick = { this . handle Click } >

If you need to have access to the parent component in the handler, you also need to bind the function to the component instance

-https://reactjs.org/docs/faq-functions.html

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