Answer the question
In order to leave comments, you need to log in
How to change the execution order of actions in Redux?
There is an action loadUser that receives user data from the REST API using a token (stored in localStorage) and puts it in the global state. It is called in the componentDidMount of the App component, which is the topmost one, the parent of all other components, so to speak.
The action getArtObjects is called in componentDidMount of the Artobjects component. He, using data about the user from the global state, should receive user pictures from the REST API.
But for some reason, when loading the Artobjects component, getArtObjects is called first of the actions, and then loadUser. Because of this, the getArtObjects action cannot get user data from the global state, maybe. they appear later.
How can I change the order in which actions are called?
Answer the question
In order to leave comments, you need to log in
But for some reason, when loading the Artobjects component, getArtObjects is called first of the actions, and then loadUser. Because of this, the getArtObjects action cannot get user data from the global state, maybe. they appear later.
const store = configureStore();
store.dispatch(clientInit()); // тут
const Root = () => (
<Provider store={store}>
<Router>
<App />
</Router>
</Provider>
);
{isInitialDataFetching ? <Preloader /> : this.renderContent()}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question