Controlled collection
for select component
#1416
-
I'm using the select component to have my own custom controlled or uncontrolled select component. I saw the section in the docs about controlled usage, so I moved my Then I had some weird issues when the const collection = select.collection({
items: options,
itemToValue: blah,
itemToString: blah,
});
const [state, send] = useMachine(
select.machine({
blah,
blah,
collection,
}),
{
context: {
collection,
value: declarativeValue,
onValueChange: () => blah,
},
}
); So, I just wanted to make sure this is okay and check if there is a better recommended way to do this. Do you foresee any issue with defining the collection at the top like that and duplicating it between the machine and the context? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It's okay to define the collection in both the initial context and the controlled context. The controlled context will override the initial context right after instantiation time. |
Beta Was this translation helpful? Give feedback.
It's okay to define the collection in both the initial context and the controlled context. The controlled context will override the initial context right after instantiation time.