-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Description
The React team has announced plans for future releases that will remove support for defaultProps in function components. This change will affect many React projects, including react-native-flags-kit. The library currently uses defaultProps for setting default values in function components, which will need to be updated to maintain compatibility with future versions of React.
Issue Details
Currently there is a warning when running an app that uses the react-native-flags-kit dependency. the exact message is:
ERROR Warning: Flag: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.
Using defaultProps in function components is warned against in React's recent updates as they plan to deprecate this feature. Instead, it's recommended to use default function parameters as a more modern approach. This enhancement aims to update react-native-flags-kit to follow these best practices.
For example, in the Flag component, the current implementation is:
const Flag = props => {
...
};
Flag.defaultProps = {
size: 64,
type: "shiny",
};
This can be refactored to:
const Flag = ({ size = 64, type = "shiny", code, style }) => {
...
};
Suggested Solution
I propose to refactor the Flag component in react-native-flags-kit that currently use defaultProps to use default function parameters. This change will align the library with upcoming React standards and improve overall code quality.
If this change is acceptable, I am willing to work on this and submit a pull request with the necessary modifications.