-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Compiling use_context hook example fails #1753
Comments
@hamza1311, care to take a look? :) |
This happens because
<ContextProvider<Rc<Theme>> context=ctx>
<Consumer />
</ContextProvider<Rc<Theme>>>
// in consumer:
let theme: Rc<Rc<Theme>> = use_context().expect("no ctx found");
The bigger problem is the hooks API as neither of those solutions are elegant. A better API was proposed in #1026 (comment) which could alleviate the problem to an extent but I'm not sure what the best solution the API problem is. |
I went with Also worth mentioning that the following line in the example needs to be without the
Although a lot of work remains to be done with the hooks, overall I am very very very impressed by the progress..! |
The underlying problem is still #1656. Then there wouldn't be any need for |
This is about:
Problem
The
use_context
hook example does not work.https://yew.rs/docs/en/next/concepts/function-components/pre-defined-hooks
Steps To Reproduce
Cargo.toml
add dependenciesQuestionaire (Optional)
The text was updated successfully, but these errors were encountered: