Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

forwardRef set via observer is not generating documentation when using react-docgen #810

Closed
thecodejack opened this issue Dec 13, 2019 · 5 comments

Comments

@thecodejack
Copy link

thecodejack commented Dec 13, 2019

I am trying to use observer with forwardRef like below

function MyReactComponent(props, ref) {
    useImperativeHandle(ref, () => ({
       handleClick:()=>{}
   })
   return <div>Test</div>
}

MyReactComponent.displayName = 'Test';

MyReactComponent.propTypes = {
    title: PropTypes.string
}

export default observer(MyReactComponent, { forwardRef: true })

For same when I try generating documentation via react-docgen, I am unable to get propTypes, displayName etc.

@danielkcz
Copy link
Contributor

I am not familiar with react-docgen. I wonder, is it working for you if you use React.forwardRef directly without the observer?

@danielkcz
Copy link
Contributor

Looks like there were some issues with that: reactjs/react-docgen#392
Can you try upgrading to the latest version to see if that fixes it for you?

@thecodejack
Copy link
Author

sure...let me try that...

@thecodejack
Copy link
Author

seems like it's working with react-docgen@5.0 when i tried here

http://reactcommunity.org/react-docgen/

@lock
Copy link

lock bot commented Feb 12, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or questions.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants