Skip to content

Export isDraft from Immer #944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/api/otherExports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ const todosReducer = createReducer(initialState, builder => {
})
```

### `isDraft`

[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.

### `combineReducers`

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.
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/immer-reducers.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ The correct output would look like this instead:

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

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.
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.

### Updating Nested Data

Expand Down
3 changes: 3 additions & 0 deletions etc/redux-toolkit.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { DeepPartial } from 'redux';
import { Dispatch } from 'redux';
import { Draft } from 'immer';
import { freeze } from 'immer';
import { isDraft } from 'immer';
import { Middleware } from 'redux';
import { original } from 'immer';
import { OutputParametricSelector } from 'reselect';
Expand Down Expand Up @@ -315,6 +316,8 @@ export function isAsyncThunkAction<AsyncThunks extends [AnyAsyncThunk, ...AnyAsy
// @public
export function isAsyncThunkAction(action: any): action is UnknownAsyncThunkAction;

export { isDraft }

// @public
export function isFulfilled(): (action: any) => action is UnknownAsyncThunkFulfilledAction;

Expand Down
256 changes: 0 additions & 256 deletions src/immutablePerfBenchmarks.ts

This file was deleted.

3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export {
Draft,
current,
freeze,
original
original,
isDraft
} from 'immer'
export {
createSelector,
Expand Down