Skip to content

How to use immutable.js with RTK (redux toolkit)? #3539

Answered by EskiMojo14
Yohandah asked this question in Q&A
Discussion options

You must be logged in to vote

the serializableCheck and immutableCheck are two separate checks, and we want you to customise them using getDefaultMiddleware.

For example, something like the below (untested) code might work:

import { configureStore, isImmutableDefault, isPlain } from "@reduxjs/toolkit";
import { isImmutable } from "immutable";

const store = configureStore({
  reducer,
  middleware: (getDefaultMiddleware) =>
    getDefaultMiddleware({
      immutableCheck: {
        isImmutable: (value) => isImmutable(value) || isImmutableDefault(value),
      },
      serializableCheck: {
        isSerializable: (value) => isImmutable(value) || isPlain(value),
        getEntries: (value) =>
          isImmutable(value)

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@Yohandah
Comment options

Answer selected by Yohandah
Comment options

You must be logged in to vote
4 replies
@markerikson
Comment options

@EskiMojo14
Comment options

@EskiMojo14
Comment options

@jdeniau
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants