Mongoose, Array In Object
Update: This problem seems to be related to mongoose. Please see update at the bottom. In the parent I use the following code to pass choosenItem to a grandChild: childContextTypes
Solution 1:
If you mean cars
is not the Array you expect (and not this.context.foo.cars
)...
The Array constructor builds an array with each argument to the constructor as an element in the returned array.
So, new Array([1,2,3])
gives you: [[1,2,3]]
.
You want Array.from([1,2,3])
which will give you [1,2,3]
which appears to be what you want.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
But with your code, why can't you just skip creating the intermediate array and just call this.context.foo.cars.map(...)
directly?
Post a Comment for "Mongoose, Array In Object"