Skip to content

Commit

Permalink
Merge pull request #2610 from NiedziolkaMichal/patch-1
Browse files Browse the repository at this point in the history
Add caseReducers & getInitialState to createSlice docs
  • Loading branch information
markerikson authored Aug 18, 2022
2 parents 448607a + 37e3c59 commit 4822769
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 4822769

Please sign in to comment.