Closed lrkwz closed 2 years ago
As documentation says:
If your Collection is rendered within a Collection array, name is not allowed as a prop.
https://iusehooks.github.io/usetheform/docs-collection
What are you trying to achieve? which is the output expected?
Have a look at https://codesandbox.io/s/collection-array-with-mui-checkbox-values-forked-bigzk?file=/src/App.js
I expected the output to be ["apple", "banana", "pineapple"]
.
your example outputs {"myPreferredFruit":[null,true,true]}
.
If you add the value
prop to each of the Checkbox
es the result is even stranger being {"myPreferredFruit":["apple","banana",true]}
(I'm confused: why does the last one have value true
instead of pineapple
?).
The only "workaround" I can think of is using object
instead of array
and the call something like Object.entries(myPreferredFruit).map(x => x[0])
to reduce the Object to a simplear and cleaner array.
BTW what is withIndex
? I didn't find it in th docs.
If you want to get back a spefic value instead of true/false from a checkbox you have to pass that value as prop to the checkbox.
Working example at: https://codesandbox.io/s/collection-array-with-mui-checkbox-values-forked-bigzk?file=/src/components/Checkbox.js
You can read about withIndex at: https://iusehooks.github.io/usetheform/docs-collection#array-collection
Thanks.
Thank you!
When I use
<Collection />
of type array build around some<Checkbox />
I receive the following error:See https://codesandbox.io/s/collection-array-with-mui-checkbox-values-zh1sv and try to replace
object
witharray