Skip to content

Commit

Permalink
Add caseReducers & getInitialState to createSlice docs
Browse files Browse the repository at this point in the history
  • Loading branch information
NiedziolkaMichal authored Aug 17, 2022
1 parent 448607a commit 37e3c59
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/api/createSlice.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ The generated `reducer` function is suitable for passing to the Redux `combineRe
You may want to consider destructuring the action creators and exporting them individually, for ease of searching
for references in a larger codebase.

The functions passed to the `reducers` parameter can be accessed through the `caseReducers` return field. This can be particularly useful for testing or direct access to reducers created inline.

Result's function `getInitialState` provides access to the initial state value given to the slice. If a lazy state initializer was provided, it will be called and a fresh value returned.

> **Note**: the result object is conceptually similar to a
> ["Redux duck" code structure](https://redux.js.org/faq/code-structure#what-should-my-file-structure-look-like-how-should-i-group-my-action-creators-and-reducers-in-my-project-where-should-my-selectors-go).
> The actual code structure you use is up to you, but there are a couple caveats to keep in mind:
Expand Down

0 comments on commit 37e3c59

Please sign in to comment.