August 2017
Beginner
374 pages
10h 41m
English
Now, there is only one thing left to do—dispatching actions to the store. You can simply pass action objects to the store.dispatch() function:
store.dispatch({ type: 'CREATE_POST', user: 'dan', text: 'hello world' })
However, it is best practice to use action creators instead, as follows:
store.dispatch(createPost('dan', 'hello world'))
Dispatching an action will result in the state being changed (by executing the reducer), and thus, the subscribed function being called:

We can now dispatch any actions we want, have the state change accordingly, ...
Read now
Unlock full access