Can I call store.subscribe method of redux in render() method of react component?

Amante Ninja

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 )

caesarsol

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Call parent method with component

From Java

Jest Enzyme test a React component that returns null in render method

From Java

Call a React component method from outside

From Java

Call a method of the child component

From Dev

Why can't I call a mutable method (and store the result) twice in a row?

From Dev

Can I use a method in a component .jsp?

From Dev

Can I call a set Method inside a Constructor

From Dev

For loop in react render method

From Dev

Can I call an async method from OnOptionsItemSelected?

From Dev

React-redux connect method unable to locate store in props

From Dev

React render method not called for nested component

From Dev

React call component's method from nested function in render method

From Dev

How to call parent method from child in react-redux

From Dev

Mojolicious: Can't call method "render" on an undefined value

From Dev

React/Flux: Firing an action from a render method of an component or doing a Rest call from a component?

From Dev

Why does React call the render method of an unchanged component?

From Dev

How to call a method in the React component in an external script

From Dev

Connecting React Component with Redux Store

From Dev

How can I call method in the component from view? (vue.js 2)

From Dev

Call method of a component in directive

From Dev

React Native FlatList - Calling A Function In The Render Method Which Returns A Component

From Dev

React Redux render connected component

From Dev

Where can I store a mapping method?

From Dev

Redux Store not connected to React Component

From Dev

How can I call method in child component from parent component?

From Dev

Return JSX from component method to render method

From Dev

React Native call a function in a render method

From Dev

How to render component from a function outside the render method in React?

From Dev

Can I bind store's state with a component in react-redux?

Related Related

  1. 1

    Call parent method with component

  2. 2

    Jest Enzyme test a React component that returns null in render method

  3. 3

    Call a React component method from outside

  4. 4

    Call a method of the child component

  5. 5

    Why can't I call a mutable method (and store the result) twice in a row?

  6. 6

    Can I use a method in a component .jsp?

  7. 7

    Can I call a set Method inside a Constructor

  8. 8

    For loop in react render method

  9. 9

    Can I call an async method from OnOptionsItemSelected?

  10. 10

    React-redux connect method unable to locate store in props

  11. 11

    React render method not called for nested component

  12. 12

    React call component's method from nested function in render method

  13. 13

    How to call parent method from child in react-redux

  14. 14

    Mojolicious: Can't call method "render" on an undefined value

  15. 15

    React/Flux: Firing an action from a render method of an component or doing a Rest call from a component?

  16. 16

    Why does React call the render method of an unchanged component?

  17. 17

    How to call a method in the React component in an external script

  18. 18

    Connecting React Component with Redux Store

  19. 19

    How can I call method in the component from view? (vue.js 2)

  20. 20

    Call method of a component in directive

  21. 21

    React Native FlatList - Calling A Function In The Render Method Which Returns A Component

  22. 22

    React Redux render connected component

  23. 23

    Where can I store a mapping method?

  24. 24

    Redux Store not connected to React Component

  25. 25

    How can I call method in child component from parent component?

  26. 26

    Return JSX from component method to render method

  27. 27

    React Native call a function in a render method

  28. 28

    How to render component from a function outside the render method in React?

  29. 29

    Can I bind store's state with a component in react-redux?

HotTag

Archive