basir / node-react-ecommerce

Build ECommerce Website Like Amazon By React & Node & MongoDB
https://node-react-ecommerce-app.herokuapp.com/
1.69k stars 794 forks source link

TypeError: Cannot destructure property 'loading' of 'userUpdate' as it is undefined. #29

Open jeffandeko opened 4 years ago

jeffandeko commented 4 years ago

21 | dispatch(update({ userId: userInfo._id, email, name, password })) 22 | } 23 | const userUpdate = useSelector(state => state.userUpdate);

24 | const { loading, success, error } = userUpdate; | ^ 25 | 26 | const myOrderList = useSelector(state => state.myOrderList); 27 | const { loading: loadingOrders, orders, error: errorOrders } = myOrderList;

basir commented 4 years ago

It means that state.userUpdate is undefined. Check the reducer to see if you initialize it or not.

bohdan-vyshynskyi commented 4 years ago

Had the same problem, but with userRegister. With userRegisterReducer.js was all okey, but needed to import and add it to combineReducers({...}) in store.js. Now all works.