-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Warn for all unsupported lifecycles in stateless Components #6926
Comments
Apparently none of the Component lifecycle events are supported, if it is intended that context is also not supported then suggest a warning to be thrown when using a non-production build of React. |
Yeah, a warning for all the lifecycles is probably a good idea. |
getChildContext
in stateless Components
Would https://github.com/facebook/react/blob/master/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js#L42 be the correct location to specify the warning? |
Yeah, that sounds like a reasonable place to me. cc @spicyj for confirmation. |
I don't think this makes much sense because the mental model is that these functions are called, not constructed – so the prototype shouldn't come into play at all. But I guess that's a reasonable place if we do want the warning. |
Yeah, but we sort of violate the mental model with contextTypes and propTypes and related properties that get set on the function. I can see how someone could think they could add a lifecycle function in the same way. There really isn't any harm in adding a warning, and it might help people catch errors in their mental model. |
If at a minimum |
Yeah, that makes sense. Let's start with childContextTypes and revisit if anyone else is confused after that. |
Example: https://jsfiddle.net/gingur/u0h2rjae/1/
When generating child context with a stateless Component, the context is not available to the children.
The text was updated successfully, but these errors were encountered: