immerjs / immer

Create the next immutable state by mutating the current one

Home Page:https://immerjs.github.io/immer/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to verify that part of the draft is array.

dyabol opened this issue Β· comments

πŸ™‹β€β™‚ Question

I have tree data structure where i can have any value. When browsing draft I need to check if the value is array, but draft is object.

I try Array.isArray(current(draftValue)) but i can have array witch millions of object. I feel potential performance issue.

I also thought to check presence of map, concat, forEach ... etc.

Is there any easy way to verify this?

Thank you

I think Array.isArray(draftValue) should also work? Or are you using Immer in ES5 mode?

I think Array.isArray(draftValue) should also work? Or are you using Immer in ES5 mode?

You are right, i must try it again in my project. In sandbox all works correctly.