mthanh2209 / react-training

https://react-training-eight.vercel.app
0 stars 0 forks source link

Implement sharing state #151 #172

Closed mthanh2209 closed 10 months ago

mthanh2209 commented 10 months ago

In this part, I have learned and given an example of the correct and reasonable way to lift state up. There will be 3 steps:

  1. Remove state from the child components.
  2. Pass to the common parent.
  3. Add state to the common parent and pass it down together with the event handlers.

When to use lifting state up?

  1. When multiple components need to access and change the same state
  2. When you want to keep the state at a higher level in the application
  3. When it is necessary to pass data between components that do not have a direct parent-child relationship
vercel[bot] commented 10 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-training ❌ Failed (Inspect) Jan 9, 2024 2:47am
storybook ❌ Failed (Inspect) Jan 9, 2024 2:47am