question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CreateSliceOptions.reducers is marked as required even though it is not

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
phryneascommented, Jan 10, 2020

@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 just extraReducers is essentially just createReducer. Wouldn’t it make more sense to just use that instead?

1reaction
markeriksoncommented, Jan 24, 2020

Yeah. Can you file a PR to add that note to the createSlice docs page or the usage guide?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found