Implementing Dispatch

Learn how to implement dispatch in your application.

Now it’s time to implement the actual change of the state. Since we are building a generic framework, we will not include the code to increment/decrement the counter but rather will call a function that we expect the user to supply, a function called reducer().

The dispatch() function calls the reducer() implemented by the application creator, passing it both the current state and the action that it received.

Get hands-on with 1400+ tech skills courses.