Skip to content
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

Stop using React's defaultProps #413

Closed
FilomenoSanchez opened this issue Jul 4, 2024 · 1 comment · Fixed by #414
Closed

Stop using React's defaultProps #413

FilomenoSanchez opened this issue Jul 4, 2024 · 1 comment · Fixed by #414
Labels
moorhen-ui Something related to moorhen UI refactor Something related to code refactoring

Comments

@FilomenoSanchez
Copy link
Member

FilomenoSanchez commented Jul 4, 2024

At the moment we are using defaultProps in multiple components. This is deprecated and will be removed in future React versions (see facebook/react#16210) which results in the following warning:

Warning: FV: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead
@FilomenoSanchez FilomenoSanchez added bug Something isn't working moorhen-ui Something related to moorhen UI refactor Something related to code refactoring labels Jul 4, 2024
@FilomenoSanchez
Copy link
Member Author

FilomenoSanchez commented Jul 4, 2024

Probably we want to do one of the following two:

export const MoorhenMapCard = (props) => {
    const { initialContour, initialRadius } = { initialContour: 0.8, initialRadius: 13, ...props }

    // ...etc.
}

// And we can now remove this:
MoorhenMapCard.defaultProps = {
    initialContour: 0.8, initialRadius: 13
}

Or instead use:

export const MoorhenMapCard = ({ initialContour = 0.8, initialRadius = 13 }) => {

    // ...etc.
}

Although the second option is only possible when the number of props is small, which is often not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
moorhen-ui Something related to moorhen UI refactor Something related to code refactoring
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant