react-events-and-state Flashcards

1
Q

What is the purpose of state in React?

A

What Is ‘State’ in ReactJS? 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.

state is nothing but an object that is privately maintained inside a component,
and the this.state can be changed inside the component of a class

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

With JSX you pass a function as the event handler, rather than a string.

this.changeMessage}>subscribe

changeMessage is a method that is defined after the component on class

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