Skip to content

thirihsumyataung/Redux-Cart-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redux Shopping Cart Project

  • Redux Stuff
  • reducer : function that used to update store
  • two arguments : state , action
  • state : old state / state before update
  • action : what happened / what update
  • return updated or old state
  • store.getState() function

Dispatch Method

  • send actions to the store
  • actions (objects) - MUST HAVE TYPE PROPERTY - what kind of action
  • DON'T MUTATE THE STATE - redux built on IMMUTABILITY (copy)

React-Redux

  • React-redux - Provider - wraps app
  • connect : used in components
  • Note : Provider will look for the prop named store

To refactore "DECREASE"

  • In CartItems.js,
onClick = { () => {
    if (amount === 1){ 
        return remove(); 
    }
    else { 
        return decrease(); 
    }
}}

  • reducer.js , just copy and paste code from "INCREASE" function

Redux-Dev-Extension

Check Redux Devtools Extension

Add this comment in App.js in order to use redux extension from Chrome

 const store = createStore(
   reducer, /* preloadedState, */
+  window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
 );

  • Note: When you deploy it on netlify , don't forget to update "build" in package.json
    "build": "CI= react-scripts build",

About

Shopping Cart page in Redux 🛒✨

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published