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

defaultProps issue with React version 18.3 #2273

Closed
Manouli opened this issue May 13, 2024 · 4 comments
Closed

defaultProps issue with React version 18.3 #2273

Manouli opened this issue May 13, 2024 · 4 comments

Comments

@Manouli
Copy link

Manouli commented May 13, 2024

Bug

I am using react-native-web inside a next js project with the react-native-svg package and the babel-plugin-inline-react-svg. It seems to be working fine. The only problem is that I am getting a warning from all my icons about defaultProps.

Example warning:

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

We don't declare any defaultProps ourselves so it must be coming from the package.

I tried replacing this setup with the svgr/webpack implementation and that would not throw any errors. Is there something that I am missing?

Library version: ^12.1.1,
"babel-plugin-inline-react-svg": "2.0.1",

@jakex7
Copy link
Member

jakex7 commented May 13, 2024

Hi @Manouli,
Thank you for reporting this issue. However, I was unable to reproduce it. Could you please provide a minimal reproducible repository?

@Manouli
Copy link
Author

Manouli commented May 13, 2024

@jakex7 https://github.com/Manouli/react-native-svg-test I have created a repo for you here.

Also here is a screenshot showing the warning in the console and in browser
image

image

@jakex7
Copy link
Member

jakex7 commented May 15, 2024

After a closer inspection, there is no defaultProps in any of our files and the warning comes from babel-plugin-inline-react-svg.
Here's the pull request introducing this feature: Use defaultProps instead of adding props to the svg #8
There's also a related PR where we can find a discussion about this topic. Provide option for spreading props rather than static assignment #86

@jakex7 jakex7 closed this as completed May 15, 2024
@Manouli
Copy link
Author

Manouli commented May 15, 2024

@jakex7 thank you! 🫡

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

2 participants