immer-adapter icon indicating copy to clipboard operation
immer-adapter copied to clipboard

not working with dynamic selector

Open admir86 opened this issue 5 years ago • 3 comments

@ImmutableSelector() is not working when using dynamic selector with arguments. See error below.

First argument to `createDraft` must be a plain object, an array, or an immerable object

repro on stackblitz: https://stackblitz.com/edit/ngxs-repro-hgjaa9?file=src/app/app.state.ts

What is the right way to guarantee immutability when using dynamic selectors?

admir86 avatar Oct 29 '19 08:10 admir86

The default primitives (String, Number, Boolean) are immutable, you don’t need then @ImmutableSelector, @ImmutableContext

splincode avatar Oct 29 '19 08:10 splincode

Hi @splincode I'm not creating a counter in my app :) this was just the simplest way to make a repro. I could change the StateModel to an object or an array, the behavior is the same.

admir86 avatar Oct 29 '19 10:10 admir86

So, I will investigate

splincode avatar Oct 29 '19 10:10 splincode