-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Controller as context #24
Controller as context #24
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey thanks, looks good. But I have to test it out first.
hey @switchnollie I am also looking at doing something like this using a hooks based approach. I am creating a custom context hook called here is my code for reference:
|
Hey there, I've been having the same problem and reading your issues and now PR - does anybody have any update on this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bitworking I just tested it and it seems good to be working well, it resolves a huge pain
I honestly assumed this was how it worked, and ended up here in search of reasons my code wasn't working out. Please accept this PR or at least call this out. |
zomg, thank you! I need to use this functionality today, and it was merged 7 hours ago! |
Haha nice, I'm sorry. I just do this in my freetime which I don't have much and currently don't use it in any project by myself. That's why changes take very long.. |
The approach using
child.type.displayName
only works if theScene
component is a direct child of theController
component.This approach uses the React Context API to pass down the
controller
prop and allows theScene
component to be anywhere in the component hierarchy (if it's a child ofController
obviously).