You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update docs on serializability usage and dev check middleware (#630)
* Add more serializability usage info
* Update Docusaurus to alpha.58
* Remove unneeded pagination CSS
* Split API ref into subcategories
* Extract API ref docs for dev check middleware
* Update API types
* Assorted typo fixes and cleanup
Alternately, youmaypassacallbackfunction that will receive `getDefaultMiddleware` as its argument,
91
+
and should return a middleware array. This lets you skip importing `getDefaultMiddleware` separately. If using TypeScript, prefer using this syntax, as we provide a more strongly-typed version of `getDefaultMiddleware` that will correctly
92
+
retain the types of the provided middleware when constructing the store.
93
+
86
94
For more details on how the `middleware` parameter works and the list of middleware that are added by default, see the
See [the `builder callback` API](#the-builder-callback-api) below for details on defining reducers using this syntax.
89
+
See the ["Builder Callback Notation"](#builder-callback-notation) section below for details on defining reducers using this syntax.
90
90
91
91
> **Note**: If you are using TypeScript, we specifically recommend using the builder callback API to get proper inference of TS types for action objects. If you do not use the builder callback and are using TypeScript, you will need to use `actionCreator.type` or `actionCreator.toString()` as the key to force the TS compiler to accept the computed property. Please see [Usage With TypeScript](./../usage/usage-with-typescript.md#type-safety-with-extraReducers) for further details.
Instead of using a plain object as an argument to `createReducer`, you can also provide a "builder callback" function that receives an `ActionReducerMapBuilder` instance:
It's very common for a developer to call `console.log(state)` during the development process. However, browsers display Proxies in a format that is hard to read, which can make console logging of Immer-based state difficult.
Copy file name to clipboardExpand all lines: docs/api/createSlice.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -154,7 +154,7 @@ createSlice({
154
154
155
155
WerecommendusingthisAPIifstrictertypesafety is necessary when defining reducer argument objects, as it will correctly infer the action type in the reducer based on the provided action creator. It's particularly useful for working with actions produced by `createAction` and `createAsyncThunk`.
156
156
157
-
See [the"builder callback API"sectionofthe`createReducer`reference](./createReducer.md#the-builder-callback-api) fordetailsonhowtouse`builder.addCase`, `builder.addMatcher`, and`builder.addDefault`
157
+
See [the"Builder Callback Notation"sectionofthe`createReducer`reference](./createReducer.md#builder-callback-notation) fordetailsonhowtouse`builder.addCase`, `builder.addMatcher`, and`builder.addDefault`
state values for mutations. It can detect mutations in reducers during a dispatch, and also mutations that occur between
77
77
dispatches (such as in a component or a selector). When a mutation is detected, it will throw an error and indicate the key
78
78
path for where the mutated value was detected in the state tree. (Forked from [`redux-immutable-state-invariant`](https://github.com/leoasis/redux-immutable-state-invariant).)
79
79
80
-
-[`serializable-state-invariant-middleware`](./otherExports.md#createserializablestateinvariantmiddleware): a custom middleware created specifically for use in Redux Toolkit. Similar in
80
+
-[Serializability check middleware](./serializabilityMiddleware.md): a custom middleware created specifically for use in Redux Toolkit. Similar in
81
81
concept to `immutable-state-invariant`, but deeply checks your state tree and your actions for non-serializable values
82
82
such as functions, Promises, Symbols, and other non-plain-JS-data values. When a non-serializable value is detected, a
83
83
console error will be printed with the key path for where the non-serializable value was detected.
@@ -103,7 +103,7 @@ const middleware = [thunk]
103
103
104
104
`getDefaultMiddleware` accepts an options object that allows customizing each middleware in two ways:
105
105
106
-
- Each middleware can be excluded from inclusion in the array by passing `false` for its corresponding field
106
+
- Each middleware can be excluded the result array by passing `false` for its corresponding field
107
107
- Each middleware can have its options customized by passing the matching options object for its corresponding field
108
108
109
109
This example shows excluding the serializable state check middleware, and passing a specific value for the thunk
A port of the [`redux-immutable-state-invariant`](https://github.com/leoasis/redux-immutable-state-invariant) middleware, customized for use with Redux Toolkit. Any detected mutations will be thrown as errors.
11
+
12
+
This middleware is added to the store by default by [`configureStore`](./configureStore.md) and [`getDefaultMiddleware`](./getDefaultMiddleware.md).
13
+
14
+
You can customize the behavior of this middleware by passing any of the supported options as the `immutableCheck` value for `getDefaultMiddleware`.
0 commit comments