When the return value of molecule is a function, for example, atomFamily, the return value of useMolecule is the result of the execution of that function.
This is because useState executes a function when it receives a function as an argument.
In this PR, make the argument given to useState a function whose value is wrapped as a setter.
This prevents unexpected function execution and returns the value from useMolecule as expected.
(translated by DeepL)
Type of change
[x] Bug fix (non-breaking change that fixes an issue)
[ ] New feature (non-breaking change that adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
[ ] Documentation or Development tools (readme, specs, tests, code formatting)
Description of the change
When the return value of molecule is a function, for example, atomFamily, the return value of useMolecule is the result of the execution of that function.
This is because useState executes a function when it receives a function as an argument.
In this PR, make the argument given to useState a function whose value is wrapped as a setter. This prevents unexpected function execution and returns the value from useMolecule as expected.
(translated by DeepL)
Type of change
Links
Checklists
Development
Paperwork
Code review