-
-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to reuse other hooks in class hook? #215
Comments
Could you share a full example? |
Any information is needed? |
Not really I just need to find some time to work on it. It's a regression Feel free to make a PR if it's urgent for you |
I imagine you are extremely busy, but I'd also like to request a fix for this. <3 |
For anyone facing this issue and want a workaround: Instead of re-using other hooks (since that causes this exception), I just re-implemented the other hooks I needed. For example, in my |
I was hoping to make my custom class hook-aware by wrapping it into a hook, but stumbled into this issue too. |
Here is a quick test for this case. I have tried looking into the code here ecbffc7#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed but honestly this is beyond something I can understand within an hour to make a PR.
|
The workaround is to use your hooks within the custom _TestHookState useTestHook() {
final state = useState(5);
return use(_TestHook(state));
} |
@rrousselGit Thanks, I will see if this can be applied in practice. Here is the more complicated code I have that fails. I know there are other ways to do that, like Riverpod, but current project I work on has only hooks and redux.
|
hey! i like the workaround with is there anything similar with |
Describe what scenario you think is uncovered by the existing examples/articles
I want to use other hook in class hook.
Describe why existing examples/articles do not cover this case
I thought I can use
useState
inHookState.build
, but it throws the following.I couldn't find the way to achieve the above.
The text was updated successfully, but these errors were encountered: