react-docgen icon indicating copy to clipboard operation
react-docgen copied to clipboard

Basic React Hooks support (useImperativeHandle only)

Open JaredReisinger opened this issue 5 years ago • 1 comments

Add detection of useImperativeHandle()-defined methods on components, including test cases and README documentation.

Additional background: I have a component I've just refactored from a class-based implementation to the new hooks-style implementation, and am publishing the documentation via Styleguidist. Somewhat to my surprise, the once-public methods on the class, which are now exposed via useImperativeHandle(), are no longer showing up in the generated documentation. Digging in, this appears to be the correct place to get those methods exposed.

Note that this does not address the desire to document custom hooks, nor does it find useCallback() handlers as those aren't exposed in an imperative way and thus shouldn't be considered a part of a component's public API.

JaredReisinger avatar Jun 02 '20 20:06 JaredReisinger

@danez, has react-docgen gone into maintenance mode? I know that for the most part, there's not a lot to do since Javascript hasn't changed that much. That said, React added hooks in 16.8.0 (February 6, 2019), 19 months ago, so adding support for this isn't exactly "cutting edge" at this point.

I've tried to make sure the proposed change is well documented and tested... is there anything else I can do to make it easier or less-risky to merge?

JaredReisinger avatar Sep 17 '20 21:09 JaredReisinger