Class based react Flashcards
What does super() do in a class based component?
it calls the parents classes constructor. So when you extend from React.Component it calls using super() calls React.Component’s constructor function.
When does componentDidMount run?
Immediately after the first render of a component.
What triggers a component to run the render method again?
Whenever props or state change a component will re render.
What is the equivalent to componentDidMount when working in a functional component?
a useEffect with an empty dependency array.
When does componentDidUpdate run?
If you define the componentDidUpdate method, React will call it immediately after your component has been re-rendered with updated props or state. This method is not called for the initial render.
When does the componentWillUnmount run? What is it useful for?
If you define the componentWillUnmount method, React will call it before your component is removed (unmounted) from the screen. This is a common place to cancel data fetching or remove subscriptions.
What does a Redux Provider do? How does it do this?
The <Provider> component makes the Redux store available to any nested components that need to access the Redux store.</Provider>
It uses React’s Context mechanism to do this.
What does React context let you do ?
Context lets components pass information deep down without explicitly passing props.