2

I'm trying to make an e-commerce store in meteor using react and redux. There is an icon in my navbar that displays total number of items added to the cart. I want to update the counter of items. If I call store.getState().numOfItems it displays total number of items added to the cart. but when I add an item to the cart, icon do not update. It only updates when I move onto other pages. (It's a single page application )

1
  • 1
    Show your code please
    – fool-dev
    Oct 6, 2016 at 9:29

1 Answer 1

4

You should not have the store in your component, only the state.

Redux will update your components to match the current state, to put it simply.

You should use the connect() function from react-redux to inject state and dispatchers in the component.

Overall, read the guide! http://redux.js.org/docs/basics/UsageWithReact.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.