Explorar el Código

HW js18 final markup fix

Ivar hace 2 años
padre
commit
63358611c9
Se han modificado 1 ficheros con 2 adiciones y 1 borrados
  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