Skip to content

Commit 4822769

Browse files
authored
Merge pull request #2610 from NiedziolkaMichal/patch-1
Add caseReducers & getInitialState to createSlice docs
2 parents 448607a + 37e3c59 commit 4822769

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

docs/api/createSlice.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ The generated `reducer` function is suitable for passing to the Redux `combineRe
213213
You may want to consider destructuring the action creators and exporting them individually, for ease of searching
214214
for references in a larger codebase.
215215

216+
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.
217+
218+
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.
219+
216220
> **Note**: the result object is conceptually similar to a
217221
> ["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).
218222
> The actual code structure you use is up to you, but there are a couple caveats to keep in mind:

0 commit comments

Comments
 (0)