We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Yes
https://mitosis.builder.io/playground/?code=JYWwDg9gTgLgBAbzgVwM4FMAi6BmBDZAGxgAUoIxU4BfOHckOAcgAEAjZYQgE3SgDpgEAPQhgMCKmComAbgBQ84ADsYffAGN0cMhSoJ5cOADc8hZOgD8ALjioYUFQHMF1RegAekWHF74i8DjIyhowQspwALIAngDCEOAQyuiqABRg5JS2upQAlIiGKBjY%2FsQ5qKkGRkam5ui2TAAW6ISEEEwANIXUuQqFUOgwyFARADzcwMYAfAgZevy1FtSjwhPTrkA
Default props are defined with ES6 default parameters.
import * as React from "react"; interface Props { value?: string; } function MyComponent({ value: "hello" }: Props) { return <div>{value}</div>; } export default MyComponent;
PS. The playground doesn't not support TypeScript at the monent.
Using defaultProps which will be removed in React 19.
defaultProps
import * as React from "react"; interface Props { value?: string; } function MyComponent(props: Props) { return <div>{props.value}</div>; } MyComponent.defaultProps = { value: "hello" }; export default MyComponent;
The error was also shown in the console.
defaultProps will be removed in place of ES6 default parameters in React 19 https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-proptypes-and-defaultprops
The text was updated successfully, but these errors were encountered:
Props destructuring might be a bit complicated to implement, in the meantime, i suggest to do:
import * as React from "react"; interface Props { value?: string; } function MyComponent(props Props) { props = { ...props, value: props.value ?? "hello", } return <div>{props.value}</div>; } export default MyComponent;
however, i agree the props destructuring way is better, beautiful and more idiomatic
Sorry, something went wrong.
No branches or pull requests
I am interested in helping provide a fix!
Yes
Which generators are impacted?
Reproduction case
https://mitosis.builder.io/playground/?code=JYWwDg9gTgLgBAbzgVwM4FMAi6BmBDZAGxgAUoIxU4BfOHckOAcgAEAjZYQgE3SgDpgEAPQhgMCKmComAbgBQ84ADsYffAGN0cMhSoJ5cOADc8hZOgD8ALjioYUFQHMF1RegAekWHF74i8DjIyhowQspwALIAngDCEOAQyuiqABRg5JS2upQAlIiGKBjY%2FsQ5qKkGRkam5ui2TAAW6ISEEEwANIXUuQqFUOgwyFARADzcwMYAfAgZevy1FtSjwhPTrkA
Expected Behaviour
Default props are defined with ES6 default parameters.
PS. The playground doesn't not support TypeScript at the monent.
Actual Behaviour
Using
defaultProps
which will be removed in React 19.The error was also shown in the console.
Additional Information
defaultProps
will be removed in place of ES6 default parameters in React 19https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-proptypes-and-defaultprops
The text was updated successfully, but these errors were encountered: