layout: post title: Dispatch date: 2018-06-06 —
dispatch(action)
Dispatches an action. This is the only way to trigger a state change. The store’s reducing function will be called with the current getState() result and the given action synchronously. Its return value will be considered the next state. It will be returned from getState() from now on, andthe change listeners will immediately be notified. mapDispatchToProps […] If an object is passed, each function inside it is assumed to be a Redux action creator. An object with the same function names, but with every action creator wrapped into a dispatch call so they may be invoked directly, will be merged into the component’s props. It means that you don’t have to dispatch your actions, just need to pass an object to connect and you can call the wrapped actions from the props.
Action (Object†):
A plain object describing the change that makes sense for your application. Actions are the only way to get data into the store, so any data, whether from the UI events, network callbacks, or other sources such as WebSockets needs to eventually be dispatched as actions. Actions must have a type field that indicates the type of action being performed. Types can be defined as constants and imported from another module. It’s better to use strings for type than Symbols because strings are serializable. An object with a type property that describes something that should result in a change of state.