reactjs - how to reduce redux boilerplate -
i'm new redux , find every little thing x turns x_success , x_failure, when fetching data or trying create new entity, , means more action creators, , more handling in reducers. what's recommended approach here? thanks.
recommended approach x_success, x_failure etc. async operations only. let's see why :
async operations in spa operations want know
when operation started,
when got response back
type of response , success or failure
so have seperate actions creator functions return objects , 1 async action creator function can return function instead of object , calls other action creators body.
for reasons above should have seperate action creators, 1 async action creator , of course every action creator should have constant in reducer.
assuming writing constants, actions , reducers in seperate folders, can nightmare. if case, should take @ here duck modular redux .
duck modular redux should definetely implement reduce boilerplate. other things seperate action creators, seperate constants, seperately checking on reducers constants required. there nothing feel bad it.
Comments
Post a Comment