Skip to content

static methods not properly handled in sort-comp #1826

Closed
@ThiefMaster

Description

@ThiefMaster

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 = {};
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions