When I was first introduced to Redux, Reducers were extremely difficult to wrap my head around. They seemed like an unnecessary source of headaches and confusion. I quickly learned how wrong I was.
See, Reducers are actually beautifully simple. At its core, a Reducer is a function that accepts the current state
and an action
as arguments, and returns a new state
in result.
(state, action) => newState
An important note here is that Reducers must not mutate the initial or current state - they always produce a new state following an action.
A Reducer can therefore be the perfect way to help with any CRUD functionality you might need. Simply call one of the case
s defined in your Reducer through a function defined in an actions
file
Top comments (0)