-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEC-139] Refactor React components "defaultProps" management (#3676)
* refactor(application-components): update components default props management * chore: add changeset * refactor: apply review feedback
- Loading branch information
1 parent
3bcdba5
commit 9504631
Showing
30 changed files
with
309 additions
and
367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
'@commercetools-frontend/application-components': patch | ||
'@commercetools-frontend/react-notifications': patch | ||
'@commercetools-frontend/application-shell': patch | ||
'@commercetools-frontend/permissions': patch | ||
'@commercetools-frontend/sdk': patch | ||
--- | ||
|
||
As part of the preparations for the upcoming update to the newest React version, we have updated how we manage components default properties as our current implementation will no longer be supported ([reference](https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-proptypes-and-defaultprops)). | ||
|
||
```ts | ||
// BEFORE | ||
type TMyComponentProps = { | ||
message: string; | ||
size: string; | ||
} | ||
|
||
function MyComponent(props: TMyComponentProps) { | ||
... | ||
} | ||
|
||
MyComponent.defaultProps = { | ||
size: 'big' | ||
} | ||
|
||
|
||
// AFTER | ||
type TMyComponentProps = { | ||
message: string; | ||
size?: string; // <--- Note this property is now defined as optional | ||
} | ||
|
||
function MyComponent({ size = 'big', ...props }: TMyComponentProps) { | ||
... | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.