Our great sponsors
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
Actually implementing a separate interface or type per action gets clunky; that's where adding libraries can help. typesafe-actions is an easy, quality library that I've used for this on a previous project. reduxjs-toolkit is even better; it provides some more structure and several useful features. As a bonus, it includes Immer built in.
Actually implementing a separate interface or type per action gets clunky; that's where adding libraries can help. typesafe-actions is an easy, quality library that I've used for this on a previous project. reduxjs-toolkit is even better; it provides some more structure and several useful features. As a bonus, it includes Immer built in.
Destructuring and recreating the state object per action within rootReducer works (e.g., {...state, name: action.payload.name || ''}), but as your reducers get more complicated, it can become unpleasant. That's where Immer helps: Immer lets you write normal mutating code (e.g., (draftState.name = action.payload.name || ''), then it takes care of figuring out how to represent that as a new object.