-
Notifications
You must be signed in to change notification settings - Fork 49
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
Support React.ElementProps
#147
Comments
@rsolomon thanks for the report! I'm not quite sure what we should do in this case. Could you give an example of how you're using this type in your code? |
For example, the material-ui library uses the https://github.com/mui-org/material-ui/blob/v1-beta/src/Menu/MenuItem.js The component itself takes in |
@rsolomon does this look right? Input: import MenuItem from 'whatever';
type Props = {
foo: React.ElementProps<typeof MenuItem>,
};
const C = (props: Props) => {}; Output: import MenuItem from 'whatever';
const C = (props) => {};
C.propTypes = {
foo: MenuItem.propTypes
? PropTypes.shape(MenuItem.propTypes).isRequired,
: PropTypes.any.isRequired,
}; Are there other situations I'm missing? |
That's correct in that scenario, though usually I've been using the props for compositions. Ex:
With the expected output being:
|
@rsolomon I implemented it for this case: const React = require('react');
const MenuItem = require('./MenuItem');
type Props = {
foo: React.ElementProps<typeof MenuItem>,
};
const C = (props: Props) => <div />; Published as 9.2.0. I don't know when I'll have time to implement the intersection case. If you're interested in implementing this, a PR would be great! If you take it on, you can use |
Flow provides a method for obtaining a component's prop types called
React.ElementProps
(documentation here).babel-plugin-flow-react-proptypes
does not recognize usage, resulting in a transpilation error along these lines:The text was updated successfully, but these errors were encountered: