TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Reducing Redux Boilerplate in TypeScript

2 点作者 sir_pepe超过 5 年前

2 条评论

acemarke超过 5 年前
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>
drublic超过 5 年前
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>