Answer the question
In order to leave comments, you need to log in
How to listen to the store and re-render the component?
There is a component that changes store.
Specifically, this is a component that listens to resize and, depending on the changes, calls dispatch.
There is another component that is not related to this in any way. Or rather, Resize is rendered in my component.
I need to change state by changing dispatch.
The structure is like this
<Modal> <-- тут надо отслеживать изменения
<Resize /> <-- тут происходит изменения store
</Modal>
Answer the question
In order to leave comments, you need to log in
From your component, you should never call dispatch at all.
In Resize you must call action which calls dispatch.
When the store performs an update, it should send a message, say, RESIZE
Quite apart from this, the Modal should, when created (for example, in componentDidMount ), subscribe to receive RESIZE messages from the store.
Upon receiving a message, Modal must respond to it, for example by calling render, changing its state via setState or via forceUpdate().
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question