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 18 warning defaultProps will be removed from function components #2919

Open
T4rk1n opened this issue Jul 11, 2024 · 2 comments · May be fixed by #2926
Open

React 18 warning defaultProps will be removed from function components #2919

T4rk1n opened this issue Jul 11, 2024 · 2 comments · May be fixed by #2926
Assignees
Labels
dash-3.0 Going in dash-3.0 release. feature something new P3 not needed for current cycle

Comments

@T4rk1n
Copy link
Contributor

T4rk1n commented Jul 11, 2024

Running an app with React 18 emit a warning that defaultProps for functions components are deprecated.

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

We use the defaultProps for our own components generator in either the generated react-docgen metadata or the typescript transpiler. We do not support newer version of react-docgen (5.4.3 is our last supported version) that may have a fix for this in their code. The typescript transpiler needs to be adapted.

Affected core components:

  • All html components.
  • dcc
    • Link
    • Loading
    • Location
    • Tab
    • Tooltip
@gvwilson gvwilson self-assigned this Jul 11, 2024
@gvwilson gvwilson added help wanted feature something new labels Jul 11, 2024
@AnnMarieW
Copy link
Collaborator

I could help with this if you like.

I verified that our current version of react-docgen works when the default props are defined in the function parameter like this:

({ a = '1' }) => <div />;

https://react-docgen.dev/docs/reference/handlers/default-props-handler

I started by updating dcc.Loading and the docstrings were generated correctly.

I'm not sure how to test this though. I don't see any warnings when I run a dash app with React 18

@gvwilson gvwilson assigned AnnMarieW and unassigned gvwilson Jul 21, 2024
@T4rk1n
Copy link
Contributor Author

T4rk1n commented Jul 22, 2024

I could help with this if you like.

I verified that our current version of react-docgen works when the default props are defined in the function parameter like this:

Great, all the core components are still in js, will need to validate if it works with the typescript components or if we need to add more code.

I'm not sure how to test this though. I don't see any warnings when I run a dash app with React 18

The deprecation starts with version 18.3.0: https://github.com/facebook/react/blob/main/CHANGELOG.md#1830-april-25-2024

That version is not listed here:

_available_react_versions = {"16.14.0", "18.2.0"}
_available_reactdom_versions = {"16.14.0", "18.2.0"}

So just need to add it.

@AnnMarieW AnnMarieW linked a pull request Jul 22, 2024 that will close this issue
6 tasks
@gvwilson gvwilson added P3 not needed for current cycle and removed help wanted labels Aug 13, 2024
@T4rk1n T4rk1n added the dash-3.0 Going in dash-3.0 release. label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dash-3.0 Going in dash-3.0 release. feature something new P3 not needed for current cycle
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants