-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setKeys()
and setItems()
do not support ArrayLike Iterables because they use [].concat()
for a shallow copy
#20
Comments
The idea with this parameter handling was that you could just pass a bare string as the key to score, if you only needed one, rather than an array with one item. The problem with using the spread operator on a string is that The constructor requires a single key string be in an array, and it's always been doc'd as an array in |
setKeys()
does not support ArrayLike Iterables
Ahhh yeah I forgot about the string case. Also, I realised I muddled the title and the text, I was referring to |
You're right, |
setKeys()
does not support ArrayLike IterablessetKeys()
and setItems()
do not support ArrayLike Iterables because they use [].concat()
for a shallow copy
Use .slice(0) instead, so that it works with more array-like things. Resolve #20.
If I were to call setItems with something like a mobx ObservableArray, to JS it is an iterable object.
So when
concat
is called at the beginning of thesetItems
function, it doesn't properly concat, due to not being an actual array. (turns into an array that contains a mobx array that contains an object).I know this is not exactly the libraries fault, but it would be nice to support ArrayLike Iterables.
I suggest that the spread operator is used instead to copy:
[...items]
as opposed to[].concat(items)
Thanks!
The text was updated successfully, but these errors were encountered: