-
-
Notifications
You must be signed in to change notification settings - Fork 232
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
Access context from lifecycle methods (static contextType = X
)
#890
Comments
Hey Raul, how's it going? I just looked up ...but I urge any and all users to avoid React context. The amount of bad architecture that spreads through codebases like mycelium just to avoid devs having to pass some arguments around is already too high. If we just manually do the little bit of boring boilerplate to pass arguments around ourselves (and lets face it, we're talking about maybe 30 seconds of boredom occasionally), then code, its dependencies, its relationships, is all explicit and clear to readers. Once you start trying to hide all of that you trade away compile-time safety for runtime assumptions, Anyway, the above is my advice for anyone considering using React context; what you do is up to you of course and I wish you luck. |
static contextType = X
)
Hi David! After reading your comments, we'll certainly reconsider whether to use contexts. We were just beginning to experiment with them. I agree 100% that it's a limitation that only one context can be accessed in the lifecycle methods, that caught my attention too. We are using specialized components up in the component tree that just hold (and I'd be interested in hearing more about the alternate techniques you mention; I see you already opened a PR to document those. |
We're trying to use React Context in order to avoid passing context objects around everywhere. Although
scalajs-react
implementsprovide
andconsume
for contexts, I couldn't find a way to invoke said contexts from Scala components' lifecycle methods.In JS it's done via
contextType
: https://github.com/japgolly/scalajs-react/blob/master/doc/CONTEXT.md.Is there a way to do this in
scalajs-react
? If not, could I request its implementation?Thank you!
/cc @cquiroz
The text was updated successfully, but these errors were encountered: