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

React 19 Compatibility: Resolve Connect(SettingsForm) defaultProps warning #38539

Closed
Tracked by #37951
coder-karen opened this issue Jul 25, 2024 · 0 comments · Fixed by #38546
Closed
Tracked by #37951

React 19 Compatibility: Resolve Connect(SettingsForm) defaultProps warning #38539

coder-karen opened this issue Jul 25, 2024 · 0 comments · Fixed by #38546
Assignees

Comments

@coder-karen
Copy link
Contributor

coder-karen commented Jul 25, 2024

Issue

With React 19, defaultProps will continue to be supported for class components (ref) and have been removed from function components in our codebase.

However a console warning exists on the Jetpack Settings page:

Warning: Connect(SettingsForm): Support for defaultProps will be removed from memo components in a future major release. Use JavaScript default parameters instead

The full stack trace, though hard to parse, indicates the issue is with the react-redux connect function and how we are using it.

react-dom.development.js:86 Warning: Connect(SettingsForm): Support for defaultProps will be removed from memo components in a future major release. Use JavaScript default parameters instead.
    at ConnectFunction (http://localhost/wp-content/plugins/jetpack/_inc/build/admin.js?ver=69be9abf13d65df6e8c0:9281:68)
    at div
    at div
    at ThemeProvider (http://localhost/wp-content/plugins/jetpack/_inc/build/admin.js?ver=69be9abf13d65df6e8c0:18910:3)
    at Settings (http://localhost/wp-content/plugins/jetpack/_inc/build/admin.js?ver=69be9abf13d65df6e8c0:66197:1)
    at C (http://localhost/wp-content/plugins/jetpack/_inc/build/admin.js?ver=69be9abf13d65df6e8c0:11976:37)
    at ConnectFunction (http://localhost/wp-content/plugins/jetpack/_inc/build/admin.js?ver=69be9abf13d65df6e8c0:9281:68)
    at div
    at div
    at div
    at Main (http://localhost/wp-content/plugins/jetpack/_inc/build/admin.js?ver=69be9abf13d65df6e8c0:54936:5)
    at C (http://localhost/wp-content/plugins/jetpack/_inc/build/admin.js?ver=69be9abf13d65df6e8c0:11976:37)
    at http://localhost/wp-includes/js/dist/data.js?ver=6f178ef23ef546c51cae:4489:25
    at ConnectFunction (http://localhost/wp-content/plugins/jetpack/_inc/build/admin.js?ver=69be9abf13d65df6e8c0:9281:68)
    at Route (http://localhost/wp-content/plugins/jetpack/_inc/build/admin.js?ver=69be9abf13d65df6e8c0:11719:29)
    at Switch (http://localhost/wp-content/plugins/jetpack/_inc/build/admin.js?ver=69be9abf13d65df6e8c0:11921:29)
    at Router (http://localhost/wp-content/plugins/jetpack/_inc/build/admin.js?ver=69be9abf13d65df6e8c0:11338:30)
    at HashRouter (http://localhost/wp-content/plugins/jetpack/_inc/build/admin.js?ver=69be9abf13d65df6e8c0:10812:35)
    at Provider (http://localhost/wp-content/plugins/jetpack/_inc/build/admin.js?ver=69be9abf13d65df6e8c0:8992:20)
    at div

The issue appears to be with the children passed into the ThemeProvider component in the Settings class - /projects/plugins/jetpack/_inc/client/settings/index.jsx - these all have a 'type' of Symbol(react.memo) when children is logged into the console.

Solution

On more investigation, it appears as though the issue is the SearchableModules component passed into ThemeProvider via Settings - SearchableModules uses defaultProps. None of the others do (and the 'type' mentioned above was a red flag).

Parent issue: #37951

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

Successfully merging a pull request may close this issue.

1 participant