-
Notifications
You must be signed in to change notification settings - Fork 61
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
PropTypes in contextTypes and childContextTypes #77
Comments
@insin That sounds like a good idea. I could only find one counter arguments. |
I agree, that's sound advice for end users, but library implementers currently have to use |
It would also be cool to have this transform available as a |
I don't follow, what does that correspond to? |
+1, trying to build a server side rendering solution where i want to be able to drop in another module instead of react, and would be nice to be able to skip implementing all the prop types. Ie, for my use case I will transform import React from 'react';
// or
const React = require('react'); into import React from 'jsx-node';
// or
const React = require('jsx-node'); which is quite easy to do, except for the prop types. Definately not impossible, but i would prefer not to. I also use preact sometimes like OP mentioned. |
|
It's important to note that the context API is likely going to change: reactjs/rfcs#2. |
The current context API has been deprecated. We close the issue :). |
Could this transform also do something with
contextTypes
andchildContextTypes
?They're the only other places
PropTypes
are used AFAIK, so handling them too would allow complete removal ofPropTypes
from an app's own production built code. This would also be useful for slimming down the production build of libraries which use context while still allowing PropTypes to be validated in development.React doesn't care which values they have in production, but uses their property names to validate that only expected child context is provided and to mask context properties which are made available to a child, so they should be wrapped by default rather than removed (although you might still want to be able remove them if doing a cross-compatible build for something like Preact, which implements context without
contextTypes
andchildContextTypes
).Example input and expected output:
The text was updated successfully, but these errors were encountered: