U
U
Username2018-08-29 20:49:23
React
Username, 2018-08-29 20:49:23

How to call dispatch?

How to dispatch an action from any js file?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-08-29
@dalv_happy

If you mean calling outside of React or async aciton components, then this:
In your entry point:

export const store = configureStore();

// some code

In target file:
import { store } from './index';
import { someAction } from './actions/some';

store.dispatch(someAction());

But this is not good practice. It is more correct to write asyncAction and call it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question