Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Ensure componentMethodsHandler ignores private properties #440

Merged
merged 2 commits into from
Dec 13, 2020

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 pushed 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
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants