Skip to content

static methods not properly handled in sort-comp #1826

New issue

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

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

Already on GitHub? Sign in to your account

Closed
ThiefMaster opened this issue Jun 14, 2018 · 2 comments
Closed

static methods not properly handled in sort-comp #1826

ThiefMaster opened this issue Jun 14, 2018 · 2 comments

Comments

@ThiefMaster
Copy link
Contributor

According to the defaults static methods come before lifecycle (including constructor) and everything-else. Why does it want me to move gDSFP after the constructor?

30:5 warning getDerivedStateFromProps should be placed after constructor react/sort-comp

This is my component:

export default class FilterFormComponent extends React.Component {
    static propTypes = {
        setParentField: propTypes.func.isRequired
    };

    static getDerivedStateFromProps(props, prevState) {
        // override internal state from props.
        // this allows other widgets and reducers to perform
        // corrections which will be reflected next time the
        // component is rendered
        return {...prevState, ...props};
    }

    constructor(props) {
        super(props);
        this.state = {};
    }
}
@ThiefMaster ThiefMaster changed the title static properties not properly handled in sort-comp static methods not properly handled in sort-comp Jun 14, 2018
@ThiefMaster
Copy link
Contributor Author

Looking at the code again, it seems like getDerivedStateFromProps is considered lifecycle even though it is static.

@ThiefMaster
Copy link
Contributor Author

nvm, just found #1795 so I'll continue there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant