CreateSliceOptions.reducers is marked as required even though it is not
See original GitHub issueI found this while writing some slices that only needed extraReducers
(because they reused actions from other slices)
Here is the line where it uses a default map if options.reducers
is falsy
https://github.com/reduxjs/redux-toolkit/blob/master/src/createSlice.ts#L211
Let me know if you want me to file a PR, although I don’t understand exactly why the public definition of createSlice
doesn’t match the internal one and uses RestrictCaseReducerDefinitionsToMatchReducerAndPrepare
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
How to fix typescript error in redux-toolkit? - Stack Overflow
(Not recommended) You can return an entirely new state. I am using parentheses around curly braces to return an object with the property ......
Read more >redux-toolkit.umd.js.map - UNPKG
n\t// but also, we need to be able to determine from the target what the relevant ... not passed\r\n\r\n // In production we...
Read more >redux-starter-kit @ 0.4.3 .. 0.5.0 - Package Diff
- A `configureStore()` function with simplified configuration options. It can automatically combine your slice reducers, adds whatever Redux middleware you ...
Read more >2021年04月_weixin_39915267的博客_CSDN博客
Events are not triggered when running in background. 2021-01-12 ... CreateSliceOptions.reducers is marked as required even though it is not. 2021-01-11 ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@gaspardip I just gave this a try and making
reducers
optional or creating a second function signature creates lots of problems in the inference of reducer types, so I’d rather not do that.Also, I have a second thought:
createSlice
with justextraReducers
is essentially justcreateReducer
. Wouldn’t it make more sense to just use that instead?Yeah. Can you file a PR to add that note to the
createSlice
docs page or the usage guide?