Procházet zdrojové kódy

HW js18 final markup fix

Ivar před 2 roky
rodič
revize
63358611c9
1 změnil soubory, kde provedl 2 přidání a 1 odebrání
  1. 2 1
      js/18_redux-thunk-3/index.js

+ 2 - 1
js/18_redux-thunk-3/index.js

@@ -100,9 +100,10 @@ const actionAuthLogout = () => ({type: 'AUTH_LOGOUT'})
 function cartReducer (state={}, {type, good={}, count=1}) {
 
     // if (!state) {
+    //     localStorage.cart = JSON.stringify({}) 
     //     return {}
     // } 
-    if (Object.keys(state).length === 0) {
+    if (Object.keys(state).length === 0 && localStorage.cart) {
         let currCart = JSON.parse(localStorage.cart)
         if (currCart && Object.keys(currCart).length !== 0) {
             state = currCart