Second argument for useMachine
#994
-
In the usage example for combobox, second argument is used for What is the meaning of that |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi @niksy, The second argument to the useMachine hook can be used to sync/update the machine's context at runtime. The first argument's context represents the "initial" context of the machine. It can't be updated afterward. In this case, the collection needs to be kept in sync so that keyboard navigation and value retrieval can work as expected. For a static select component where the options are known ahead of time, the initial collection works just fine. In the case of dynamically changing items, then it needs to be kept in sync with the machine. |
Beta Was this translation helpful? Give feedback.
-
Thank you! |
Beta Was this translation helpful? Give feedback.
-
Hello, |
Beta Was this translation helpful? Give feedback.
Hi @niksy,
The second argument to the useMachine hook can be used to sync/update the machine's context at runtime.
The first argument's context represents the "initial" context of the machine. It can't be updated afterward. In this case, the collection needs to be kept in sync so that keyboard navigation and value retrieval can work as expected.
For a static select component where the options are known ahead of time, the initial collection works just fine. In the case of dynamically changing items, then it needs to be kept in sync with the machine.