r/learnjavascript • • Jul 14 '26

Question about lodash.isEmpty inside an RTK 2.12 reducer

Hi everyone,

I may be missing something about how draft state is expected to behave in Redux Toolkit, so I’d appreciate some guidance.

I have a reducer that uses lodash.isEmpty on part of the state:

import { createSlice } from "@reduxjs/toolkit"
import isEmpty from "lodash/isEmpty"

const slice = createSlice({
  name: "test",
  initialState: {
    data: {}
  },
  reducers: {
    update(state) {
      console.log(isEmpty(state.data))
    }
  }
})

After upgrading to RTK 2.12, this started throwing:

TypeError: 'get' on proxy: property 'prototype' is a read-only
and non-configurable data property on the proxy target but the
proxy did not return its actual value

From what I could understand, Lodash reads something similar to:

value.constructor.prototype

and constructor on the draft appears to be another proxy.

The same code worked before the upgrade, and reverting the RTK version resolves the issue.

Is lodash.isEmpty no longer expected to work directly on draft state, or could this be an unintended regression? I’d be glad to provide a reproduction or any additional details that would help clarify it.

Thanks!

1 Upvotes

5 comments sorted by

View all comments

Show parent comment

1

u/Glittering_Goose8695 Jul 14 '26

Thanks for taking the time to reply. I appreciate your perspective.

That said, it wasn’t really what I was asking. I don’t expect every library to be compatible with every other library.

The suggested workarounds certainly avoid the issue, but they don’t answer the question. Downgrading also isn’t a long-term option for me, so I’m trying to understand whether the behavior change is intentional or a regression.

Since the same code worked before upgrading RTK, and the upgrade was only a minor version, I was surprised by the change in behavior.

I couldn’t find anything in the 2.12 release notes mentioning an intentional change around this, so I was wondering whether this might be an unintended regression rather than expected behavior.

1

u/azhder Jul 14 '26

Screw the docs then, look at the code. There is a change and it involves proxies, right? So, if you’re that interested, put your Indiana Jones hat on and start digging.

On a semi related note, I also had a run in with proxies (the concept if not the JS object) just yesterday and it prevented me from having to use a nice pattern I had in the past. Such is life.

Cue in Living On A Proxy song