esamattis / immer-reducer

Type-safe and terse reducers with Typescript for React Hooks and Redux
http://npm.im/immer-reducer
MIT License
224 stars 15 forks source link

Share example project on README? #50

Open bhgsbatista opened 4 years ago

bhgsbatista commented 4 years ago

Using ImmerReducer with TypeScript is such a pleasant experience, everything is type-safe, and with some extra work you can have the compiler enforce immutability on the state outside of producers.

I built a little React based calendar app that uses two ImmerReducers for state management. This example provides a useful foundation to build a more complex app made up of several small reducers:

https://github.com/gamedevsam/calendar-appointments

The magic sauce are these files in the Redux directory:

And of course the connector components:

One other noteworthy thing is the immutable generic type, which allows TypeScript to enforce immutability at compile time: src/types/immutable.ts


image