-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Implement context #7
Comments
@sheepsteak Is there any impact on JSX/hyperscript in adding context? I'm curious whether this should be part of Is there a specific use-case you have for Definitely looking for more insight on this 👍 |
@developit not too sure what you mean about "any impact on JSX/hyperscript". Do you mean any breaking changes to JSX as to how it would be implemented? I personally use contexts all the time and a lot of people I talk to about React are the same. It's especially useful when you're doing server rendering and Flux because you then have a way to define the lifetime of your stores that is the same as the client. That's one use case. I've also used it when building component libraries. Imagine you have some components that can change style/colour (some sort of multi-tenancy). A nice way of handling this is passing something down on the context like I fully agree that anything If you're not necessarily wanting it in core, maybe it could be a separate module somehow? I guess |
It seems like this is going to need to be in core, if only because it touches on so many parts of the lifecycle as you said. I've also run into a few things that would benefit from it (universal rendering and nested routers in preact-router). I should have time this week to get contexts added, will be looking for help with real-world tests though. |
+ I will probably take this as a chance to address #3 as well, that will help with clutter. |
👍 I can help with some tests. |
Context in React is a good concept of explicit "stream" of data flowing down the tree and it serves a specific purpose. If a component needs something, it explicitly asks for it (by contextTypes) so it's not automagically injected in to each component. It's useful for things like |
@antitoxic Agreed regarding |
Cool! In that case, sorry that i brought you a ~useless github notification 😄 |
No problem, it was a good reminder that I will need to add context support to preact-router's |
Context is the main hook for redux-router to hook into it actually. Since it's one of the more widely used abstraction layers currently. https://github.com/rackt/react-redux/blob/master/src/components/Provider.js |
I just published a prerelease of 3.0 which supports |
@developit: Does this context api support the |
@shiftyp Yup! Let me know if you're able to test against the beta, I would love your feedback! |
Now generally available as of |
@developit Hi, did you mean that
Update: Update2: So no worries and everything is fine I guess ;) |
Not sure if this is planned already but it seems like contexts are the main thing missing before getting parity with React.
This will mean adding lifecycle hooks for
getChildContext
andcontextTypes
as well as passing the context into theconstructor
,render
(?) andshouldComponentUpdate
.The text was updated successfully, but these errors were encountered: