You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
New Array generates an array with a length of 3, not including values. that's way is undefined
the generated array looks like this.
[key]:value
0:undefined
1:undefined
2:undefined
For new array from a number you should do,
const stuff = [...new Array(3).keys()];
const stuff = Array.from(new Array(3).keys());
Bug report
Sandbox link or minimal reproduction code
https://codesandbox.io/s/mobx-state-tree-using-new-array-n-constructor-in-snapshot-doesnt-work-ehd5ib
Describe the expected behavior
If I use
Array.new(3)
for atypes.array(types.maybe(types.number))
it should be[undefined,undefined,undefined]
.Describe the observed behavior
It is put in the store as an empty array
[]
.Even crazier
If you
a = Array.new(3); a.fill(undefined)
, then it correctly inserts[undefined,undefined,undefined]
🤯The text was updated successfully, but these errors were encountered: