-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
-
-
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
Add support for use_context hook #1057
Comments
@ZainlessBrombie do you want to take this one? |
Sure :) |
Also I'm gonna have to use a HashMap<TypeId, Other> in there somewhere to keep track of the current Context for each context type 🤔 |
Sounds reasonable, I haven't thought about the implementation too much yet
I wonder if |
I'm not sure how contexts would be popped off the stack though.. maybe we do need an |
Yes thats What I meant, we need to be able to nest contexts and have them run in parallel, the map is just a part of it :) |
what do you mean by have them run in parallel? |
Bad way to put it, my bad - I meant to have two context providers next to each other like
|
Ah yeah, understood 👍 So do you think we will need |
Don't think so, they would be pushed onto the stack before the function renders and popped off after it is done rendering, both in the view method |
Ah, right! Never mind 😄 |
Actually you were correct. We do need a method that runs after a component was rendered. More specifically we need:
|
I would do that myself but it seems to me that it's 20% code and 80% knowing where to place it 😬 |
Ok! I'll add that as soon as I can, I think I have a branch laying around still. Tricky part is the scheduler :)
Of course! Yew has very little drama so far, hope it stays that way! It's a lot of fun to work together with the community on things |
@ZainlessBrombie I just created #1151 which should unblock context hooks! |
So I started looking into this issue. Currently I'm considering a bit of a different approach though. Instead of maintaining a stack of contexts, which doesn't work out as nicely because of the rendering order and all that, I'm thinking, The problem I'm having is that in order to do this From what I can tell there's no way to grab the scope for the current context yet One option would be to add a Does this sound reasonable in any way or am I completely off here? Either way it seems to me that |
@siku2 sounds reasonable to me! |
I'm most excited for
use_context
to be used in Yew! I think it should be possible to make providers using nested components. I imagine we will match React's implementation pretty closely: https://reactjs.org/docs/hooks-reference.html#usecontextThe text was updated successfully, but these errors were encountered: