question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support static class getter propTypes

See original GitHub issue

With classes you can also define your propTypes on a static getter property, which this plugin doesn’t seem to be able to remove currently.

Example:

class MyComponent extends React.Component {
    static get propTypes() {
        return {
            children: PropTypes.node.isRequired
        };
    }

    render() {
        return this.props.children;
    }
}

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:13
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

13reactions
omichelsencommented, Feb 22, 2018

Would like this too, just adding another syntax that is almost similar for completeness:

export default class MyComponent extends React.Component {
  static propTypes = {
    children: PropTypes.node.isRequired,
  }
0reactions
Lazzaro83commented, Aug 20, 2019

Is there any progress on this? I am using this babel plugin but, I still have propTypes that are static fields in my components being transpiled into webpack bundle.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support propTypes defined using static getter : WEB-32279
WebStorm doesn't provide code completion for props when they are defined using static getter. class App extends Component { static get propTypes() {...
Read more >
Is it OK to put propTypes and defaultProps as static props ...
Oh yes, it's totaly legit with Babel (or other transpilers) ... ...as it gets transpiled to this anyway. class DataLoader extends React.Component {}...
Read more >
Bountysource
Support static class getter propTypes. ... Contact Us. support@bountysource.zendesk.com · @bountysource on Twitter; Bountysource on Facebook ...
Read more >
Typechecking With PropTypes - React
Since ES2022 you can also declare defaultProps as static property within a React component class. For more information, see the class public static...
Read more >
How to use the prop-types.instanceOf function in prop ... - Snyk
To help you get started, we've selected a few prop-types. ... class FilteringCounterBadge extends BaseLabel { static propTypes = { alertStore: PropTypes.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found