Skip to content

Deprecation Warning: defaultProps in Function Components #535

@joeyAddy

Description

@joeyAddy

Hello Xavier,

I’ve been using your package and noticed a warning that could be addressed to ensure future compatibility. The warning is:

Warning: CountryList: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.

This warning occurs because some components in the package use the defaultProps pattern, like this:

Component.defaultProps = {
  prop1: 'defaultValue1',
  prop2: 'defaultValue2'
}

To resolve this, the components could be updated to use JavaScript default parameters, like so:

function Component({ prop1 = 'defaultValue1', prop2 = 'defaultValue2' }) {
  // Component logic here
}

As React is deprecating defaultProps for function components in future releases, I suggest updating the components to use JavaScript default parameters instead.

I’d be happy to contribute to this update if you’re open to it. Please let me know if this is something you’d like to pursue, and I can submit a pull request with the necessary changes.

Thank you for your time and for creating this package!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions