Skip to content

Commit 63a2ba7

Browse files
authored
Export isDraft from Immer (#944)
1 parent 3191483 commit 63a2ba7

File tree

5 files changed

+10
-258
lines changed

5 files changed

+10
-258
lines changed

docs/api/otherExports.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ const todosReducer = createReducer(initialState, builder => {
5252
})
5353
```
5454

55+
### `isDraft`
56+
57+
[The `isDraft` function](https://immerjs.github.io/immer/original) from the [`immer` library](https://immerjs.github.io/immer/), which checks to see if a given value is a Proxy-wrapped "draft" state.
58+
5559
### `combineReducers`
5660

5761
Redux's [`combineReducers`](https://redux.js.org/api/combinereducers), re-exported for convenience. While `configureStore` calls this internally, you may wish to call it yourself to compose multiple levels of slice reducers.

docs/usage/immer-reducers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ The correct output would look like this instead:
386386

387387
![Logged current value](/img/usage/immer-reducers/logged-current-state.png)
388388

389-
Immer also provides [`original` and `isDraft` functions](https://immerjs.github.io/immer/original), which retrieves the original data without any updates applied and check to see if a given value is a Proxy-wrapped draft. As of RTK 1.5.0, neither of those is re-exported - you'll need to specifically import them from `immer` yourself. We may re-export them from RTK in an upcoming release.
389+
Immer also provides [`original` and `isDraft` functions](https://immerjs.github.io/immer/original), which retrieves the original data without any updates applied and check to see if a given value is a Proxy-wrapped draft. As of RTK 1.5.1, both of those are re-exported from RTK as well.
390390

391391
### Updating Nested Data
392392

etc/redux-toolkit.api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { DeepPartial } from 'redux';
1414
import { Dispatch } from 'redux';
1515
import { Draft } from 'immer';
1616
import { freeze } from 'immer';
17+
import { isDraft } from 'immer';
1718
import { Middleware } from 'redux';
1819
import { original } from 'immer';
1920
import { OutputParametricSelector } from 'reselect';
@@ -315,6 +316,8 @@ export function isAsyncThunkAction<AsyncThunks extends [AnyAsyncThunk, ...AnyAsy
315316
// @public
316317
export function isAsyncThunkAction(action: any): action is UnknownAsyncThunkAction;
317318

319+
export { isDraft }
320+
318321
// @public
319322
export function isFulfilled(): (action: any) => action is UnknownAsyncThunkFulfilledAction;
320323

src/immutablePerfBenchmarks.ts

Lines changed: 0 additions & 256 deletions
This file was deleted.

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ export {
55
Draft,
66
current,
77
freeze,
8-
original
8+
original,
9+
isDraft
910
} from 'immer'
1011
export {
1112
createSelector,

0 commit comments

Comments
 (0)