-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
PropsTable is not working with components encapsulated by React.forwardRef() #334
Comments
I have found a solution but it looks ugly. // ./MyComponent.js
const WrappedComponent = React.forwardRef(
function MyComponent(props, ref) {
return <StyledComponent innerRef={ref} {...props} />;
}
); or // ./MyComponent.js
const MyComponent = (props, ref) => (
<StyledComponent innerRef={ref} {...props} />;
);
export default React.forwardRef(MyComponent); // ./MyComponent.mdx
<PropsTable of={WrappedComponent.render} /> |
@sandiiarov |
@Jared-Dev Yeah I know. It doesn't matter in that example. |
It looks like as soon as your component is wrapped inside a HOC, it won't render the prop types. Quickest solution for now is to also export your component as a named export without the HOCs. That way your prop types will work again. |
Hi PropsTable uses 2 solutions :
By default Otherwise you should export the wrapped component (like in the first solution) to have access to |
@jnaudin Thanks for posting such detailed solutions. The first one works great, but the second one I got |
I think that this will be fixed in the v1 ✌️ |
I think you imported the wrapped component and not the HOC: Can you show me what your code ? |
Closed in favor of the newest release. |
<PropsTable of={Input} />
only works when I remove theReact.forwardRef()
. The following code is Typescript, and I also havetypescript: true
on my config.The text was updated successfully, but these errors were encountered: