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

Deprecation Warning for defaultProps in Function Components #376

Open
MechanikGamer opened this issue Dec 6, 2024 · 0 comments
Open

Deprecation Warning for defaultProps in Function Components #376

MechanikGamer opened this issue Dec 6, 2024 · 0 comments

Comments

@MechanikGamer
Copy link

When using react-native-pell-rich-editor, the following warning is displayed in the console during development:

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

This warning indicates that defaultProps is being used in one or more functional components within the library, which is deprecated in newer versions of React.

Steps to Reproduce
Install and set up the latest version of react-native-pell-rich-editor.
Add a RichEditor or RichToolbar component to your project.
Run the app in development mode.
Observe the warning in the console.
Expected Behavior
No warnings should appear related to defaultProps.

Actual Behavior
The console shows the deprecation warning.

Environment
Library Version: 1.9.0
React Version:18.3.1
React Native Version:0.76.3
Platform: (both)
Proposed Solution
Replace the use of defaultProps in functional components with default values using JavaScript default parameters.

Example:

jsx
Copy code
// Before
const MyComponent: React.FC<{ title?: string }> = ({ title }) => {
return {title};
};

MyComponent.defaultProps = {
title: 'Default Title',
};

// After
const MyComponent: React.FC<{ title?: string }> = ({ title = 'Default Title' }) => {
return {title};
};
This change ensures compatibility with the current and future versions of React, where defaultProps for functional components will no longer be supported.

Additional Notes
This warning may not currently affect functionality but will become an issue in future React versions.

Thank you for maintaining this library and considering this request!

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

No branches or pull requests

1 participant