Using State
Explore how Redux Thunk allows accessing the current state within action creators to conditionally dispatch actions. Learn to prevent duplicate recipe titles by checking state before dispatching, improving validation and keeping reducers simple.
We'll cover the following...
We'll cover the following...
Another feature we gain by using redux-thunk is access to the state when processing the action. This allows us to dispatch or suppress actions according to the current application state. For example, we can prevent actions from trying to add recipes with duplicate titles:
const addRecipe = (title) ...