- Why is it always a good idea to initialize the state of a component?
- Because if you don't, React will throw an error when you try to render.
- Because React won't know what types you have in your component state and won't be able to optimize rendering.
- Because if the render() method expects state values, you need to make sure they're always there to avoid unexpected rendering behavior.
- When should you use properties instead of state?
- State should only be used for values that can change. For everything else, properties should be used.
- You should avoid state wherever possible.
- You should only use properties to update existing state.
- What is a context in React?
- Context is how you pass event handler functions to different components in your app.
- Context is used to avoid transient properties. Contexts are used to share common data with a select number of components.
- Context is like state that's shared between components.
..................Content has been hidden....................
You can't read the all page of ebook, please click
here login for view all page.