Quickupdate

  • Home
  • Top Trending
    • Top Android Apps
    • Top Ios Apps
  • Featured
  • About Us
  • Contact us
  • Privacy Policy and Disclaimer

Sunday, 17 October 2021

What is Redux? Why use Redux? When use Redux?

 Developers     October 17, 2021     No comments   

Why use Redux?

  1.  Redux helps us to avoid the problem of prop drilling!
  2. Instead of asking data to parent components, you can directly get that from the store.
  3. Create Big apps with Redux if your app shares a lot of data between components you should use Redux.
  4. Store, Reducers, Actions, Constants
  5. Data can be separated using `Multiple reducers` & will be stored in a single Store.
  6. in Index.js import Provider & Store. And then Wrap <App /> component with Provider.

Redux Devtools Extension.
  1. To view states in our dev tools. you can see state movements. 
  2. you have to add/connect your app redux dev tools extension.
  3. const store = createStore(rootReducer, composeWithDevTools());

Add to Cart Example:

  1.  What is Action: Send data from React to Store. if you click on the `Add to cart` button data will be shown to the cart.
  2.  Reducer:  Gets data from action & pushes data to store. check for the action & push data accordingly!
  3. container: 
  4. Connect React with Redux: (mapStateToProps & mapDispatchToProps)
    1. Shopping Types
    2. Shopping Actions
    3. Shopping Reducers
  5. Get to know about Connect function in Redux.

Amazed:
  1. By just adding `+`  before `action.payload.qty` type `string` value has been converted to type `number`

console.log("action.payload.qty ===> ", action.payload, " type ===>", typeof +action.payload.qty)




  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook
Newer Post Older Post Home

0 comments:

Post a Comment

Popular Posts

  • How to upload the existing folder on GitHub Or GitLab?
    These are the steps to upload the existing folder on GitHub Or GitLab. Whenever you want to push your existing folder to git or GitHub you m...

Categories

  • FAANG (2)
  • Javascript (6)
  • Node (1)
  • Project Management (1)
  • React (9)
  • SQL (1)
  • Testing (1)

Blog Archive

  • January 2023 (1)
  • January 2022 (1)
  • November 2021 (3)
  • October 2021 (3)
  • August 2021 (1)
  • July 2021 (7)
  • June 2021 (12)
  • February 2021 (1)
  • January 2021 (1)
  • January 2020 (3)
  • August 2019 (3)