Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

FWIW, our standard recommended Redux usage patterns for the last couple years have specifically _not_ needed switch statements to determine how to handle an action, because our official Redux Toolkit package has a `createSlice` API that lets you define case reducers as simple functions in an object. `createSlice` then generates all the action types internally, generates corresponding action creator functions, and handles calling the right case reducer when that action is dispatched.

Additionally, RTK has been designed to work great with TypeScript. Typically all you need to declare is the type of the state for that slice, and the payload for each reducer's action, and everything else is inferred.

See our Redux docs tutorials for details:

https://redux.js.org/tutorials/essentials/part-2-app-structu...

https://redux.js.org/tutorials/fundamentals/part-8-modern-re...

https://redux.js.org/tutorials/typescript-quick-start



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: