TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Reducing Redux Boilerplate in TypeScript

2 pointsby sir_pepeover 5 years ago

2 comments

acemarkeover 5 years ago
Hi, I&#x27;m a Redux maintainer.<p>There&#x27;s a much better solution than what this blog describes. We&#x27;ve just released a new package called Redux Starter Kit [0], which is meant to provide opinionated defaults and simplify writing common Redux code patterns. It&#x27;s already written in TypeScript, and works great in TS apps.<p>In particular, the `createSlice` function [1] allows you to provide reducer functions that use &quot;mutative&quot; update logic (thanks to using the Immer library [2] internally), and auto-generates action types and action creators based on the provided reducers. Really, there&#x27;s no reason to write an action creator or action type by hand ever again. `createSlice` also makes it really easy to organize your Redux logic using the single-file-per-feature &quot;ducks&quot; pattern [3]<p>The &quot;Advanced Tutorial&quot; page [4] shows how to use RSK with TypeScript, and with our new React-Redux hooks.<p>Going forward, Redux Starter Kit is our recommended way to use Redux.<p>[0] <a href="https:&#x2F;&#x2F;redux-starter-kit.js.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;redux-starter-kit.js.org&#x2F;</a><p>[1] <a href="https:&#x2F;&#x2F;redux-starter-kit.js.org&#x2F;api&#x2F;createSlice" rel="nofollow">https:&#x2F;&#x2F;redux-starter-kit.js.org&#x2F;api&#x2F;createSlice</a><p>[2] <a href="https:&#x2F;&#x2F;immerjs.github.io&#x2F;immer&#x2F;docs&#x2F;introduction" rel="nofollow">https:&#x2F;&#x2F;immerjs.github.io&#x2F;immer&#x2F;docs&#x2F;introduction</a><p>[3] <a href="https:&#x2F;&#x2F;github.com&#x2F;erikras&#x2F;ducks-modular-redux" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;erikras&#x2F;ducks-modular-redux</a><p>[4] <a href="https:&#x2F;&#x2F;redux-starter-kit.js.org&#x2F;tutorials&#x2F;advanced-tutorial" rel="nofollow">https:&#x2F;&#x2F;redux-starter-kit.js.org&#x2F;tutorials&#x2F;advanced-tutorial</a>
drublicover 5 years ago
The concept of action types inferred from module types is something we use in Warhol’s code a lot. It also fits nicely with the architecture of Conceptual Components as I described in my blog post here: <a href="https:&#x2F;&#x2F;drublic.de&#x2F;blog&#x2F;conceptual-components&#x2F;" rel="nofollow">https:&#x2F;&#x2F;drublic.de&#x2F;blog&#x2F;conceptual-components&#x2F;</a>