View on GitHub

reading-notes

Reading: Advanced State with Reducers

Review, Research, and Discussion

  1. How can we ensure that an effect hook runs only once?
    • by adding an empty array as a second parameters
  2. Can useState() update more than one state variable at the same time?
    • yes, we can have multiple states inside of a single component: call multiple times useState()
  3. Is useState() synchronous?
    • useState and setState both are asynchronous. They do not update the state immediately but have queues that are used to update the state object. This is done to improve the performance of the rendering of React components
## Documentation :
State Hook
A Hook is a special function that lets you “hook into” React features. For example, useState is a Hook that lets you add React state to function components. We’ll learn other Hooks later
Component Lifecycle
Every React Component has a lifecycle of its own, lifecycle of a component can be defined as the series of methods that are invoked in different stages of the component’s existence. … Mounting: Mounting is the stage of rendering the JSX returned by the render method itself

preview :