Components using use_state cannot be safely rendered conditionally. Doing so can lead to a panic, with the following error message: "insufficient calls".
Here is a minimal reproducible example:
https://gist.github.com/ebenpack/3b0c3a1a2b813740003f6a4161ce8ecf
This appears to be due to the "hook rules", however it's surprising that these rules must be adhered to for the scope of the entire application. I would expect the rule to be scoped to a single component.
I'm not sure if the way this rule is applied is intended or not, but if it is I think the library would be much more usable with a more locally applied rule. E.g. it would make conditional rendering much easier and safer.
Components using
use_statecannot be safely rendered conditionally. Doing so can lead to a panic, with the following error message: "insufficient calls".Here is a minimal reproducible example:
https://gist.github.com/ebenpack/3b0c3a1a2b813740003f6a4161ce8ecf
This appears to be due to the "hook rules", however it's surprising that these rules must be adhered to for the scope of the entire application. I would expect the rule to be scoped to a single component.
I'm not sure if the way this rule is applied is intended or not, but if it is I think the library would be much more usable with a more locally applied rule. E.g. it would make conditional rendering much easier and safer.