You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I've just jumped into Redux and like it very much so far.
Not sure if I understand completely how it works, but in Actions there is section about bounded action creator
Alternatively, you can create a bound action creator that automatically dispatches:
const boundAddTodo = (text) => dispatch(addTodo(text))
const boundCompleteTodo = (index) => dispatch(completeTodo(index))
If I understand correctly that is possible because of redux-thunk which has to be registered as middleware. And if so, shouldn't it be then be:
This has nothing to do with Redux Thunk. The term 'bound action creator' refers to the result of composing dispatch and an action creator. When this function is called it automatically dispatches the action creator. Passing this function to components allows them to be decoupled from dispatcher and actions.
This is an example from early version of docs and isn’t very relevant today.
Maybe we should just remove it as it confuses people.
Yes, the original point was to show that addTodo() by itself doesn’t do anything and you need to call dispatch(addTodo()) to actually cause the action to happen. At which point you can “bind” it to a certain dispatch function so you can just addTodo(). You can do this by hand, with bindActionCreators(), or you can use React Redux which does this for you.
Hi, I've just jumped into Redux and like it very much so far.
Not sure if I understand completely how it works, but in Actions there is section about bounded action creator
If I understand correctly that is possible because of redux-thunk which has to be registered as middleware. And if so, shouldn't it be then be:
Babel try it
The text was updated successfully, but these errors were encountered: