-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Advertise all underlying propTypes and typings in wrapper components #1169
Comments
LGTM, I'll will make this updates in PRs that affects typings. |
Great, thanks! I've left Select / Radio unfinished on the list as I don't see all the props of their underlying components listed in their propTypes. Example, Dropdown takes a |
@levithomason I need there some clarification. Most of these pairs has a correct inheritance in typings, however, I need to make an additional check. I'm also support an idea with docs, but there is problem with TableHeaderCell.propTypes = {
...TableCell.propTypes,
as: customPropTypes.as,
children: PropTypes.node,,
}
I'm not sure that docs generation will support the first way. While second way will produce a tons of unnecessary work with handling of props: function TableHeaderCell (props) {
const { children, collapsing, icon } = props
// ...
return <TableCell collapsing={collapsing} icon={icon}>{children}</TableCell>
} |
Let me check on this, I saw another project that extended react-docgen to allow this exact usage as well. Perhaps that has been integrated in to react-docgen core by now. |
Indeed, we get some support for this. Adding your above snippet to the header cell, I get this output in the
We can use the One issue is that we need to update
This sounds like a slippery slope as well. It may be pretty tough to properly traverse the propTypes of objects imported from elsewhere. My hunch is that if it were easy, react-docgen would have included that feature rather than listing Another (much smaller) issue is that the resolve is also a little too tricky for my IDE and I'm guessing others' tools as well. This means unless you're using TS, your tool probably won't benefit much from this kind of composition. This should be taken lightly as tools will catch up someday, but it is worth considering. This is a lot to manage by hand and also creates nasty low visibility dependencies that we're going to break often. At some point, updating a Portal prop is bound to cause breakages in all the other propTypes that use it. Let's think on this a bit more. We want to reduce maintenance overhead, reduce dependencies, and increase doc visibility. |
I'll make an update to plugin on this week, it will ignore spreads. |
Won't this break the handledProps array? It needs to parse them to know which are handled and which are |
Nope.
It's a kind of black magic if we speak about external imports like in my snippet. So, it will be easier to ignore spreads at now at all. Especially, in our case, when this behavior is expected. TableHeaderCell.propTypes = {
...TableCell.propTypes,
as: customPropTypes.as,
children: PropTypes.node,
}
// will produce
TableHeaderCell.handledProps = ['as', 'children'] |
I've checked typings of all components in list. All of them now correctly extends parents, except |
Great, so we should be able to spread the inherited propTypes as well then. Once that is done, I can update |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions. |
This really needs to be done. It bites again in #2579. |
There has been no activity in this thread for 90 days. While we care about every issue and we’d love to see this fixed, the core team’s time is limited so we have to focus our attention on the issues that are most pressing. Therefore, we will likely not be able to get to this one. However, PRs for this issue will of course be accepted and welcome! If there is no more activity in the next 90 days, this issue will be closed automatically for housekeeping. To prevent this, simply leave a reply here. Thanks! |
This issue should remain open (and closing issues marked as |
There has been no activity in this thread for 180 days. While we care about every issue and we’d love to see this fixed, the core team’s time is limited so we have to focus our attention on the issues that are most pressing. Therefore, we will likely not be able to get to this one. However, PRs for this issue will of course be accepted and welcome! If there is no more activity in the next 180 days, this issue will be closed automatically for housekeeping. To prevent this, simply leave a reply here. Thanks! |
This issue will be closed due to lack of activity for 12 months. If you’d like this to be reopened, just leave a comment; we do monitor them! |
Hey @layershifter ! Is this issue still open? I'd love to work on this. |
1 similar comment
Hey @layershifter ! Is this issue still open? I'd love to work on this. |
I am new to open-source contributions and I want to contribute. Can I handle this issue? |
@Anuragtech02, @Ranzeb — don't ask, just do! It's the open source way. |
See #1163 for the inspiration here.
Some components wrap others, like a Popup wrapping a Portal. However, we do not advertise the Portal props as propTypes nor typings of the Popup. This means there is no way for users to know what props are available.
Add propTypes
I propose we explicitly list all known props in propTypes and typings of the underlying component when a component wraps another component.
Add Examples
We should then also add doc site examples showing use of these props. Example, Popup mouse enter/leave delays are not shown but are available as it composes the Portal which has mouse enter/leave delays.
Task List
Here is a brain dump of wrapper components, there may be more. @jcarbo / @layershifter feel free to update this list at will:
The text was updated successfully, but these errors were encountered: