Skip to content

Conversation

GeorgeTaveras1231
Copy link
Contributor

@GeorgeTaveras1231 GeorgeTaveras1231 commented Mar 4, 2020

Currently, react-docgen fails to parse a component that uses private properties such as

class MyComponent extends React.Component {
    #privateCallback = () => {
      console.log('Do something');
    }

    render() {
       return <button onClick={this.#privateCallback}>Click me</button>
    }
}

This fix allows react-docgen to parse this code.

Notes

  • Surprisingly t.ClassProperty.check returns true even if the property is a ClassPrivateProperty. This explains the nature of the change, and why there seems to be a seemingly contradicting line: t.ClassProperty.check(path.node) && !t.ClassPrivateProperty.check(path.node)

@danez danez merged commit 9683e67 into reactjs:master Dec 13, 2020
danez added a commit that referenced this pull request May 8, 2021
Co-authored-by: Daniel Tschinder <daniel@tschinder.de>
# Conflicts:
#	src/handlers/componentMethodsHandler.js
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants