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

Remove defaultProps to support React 18.3.0 #1650

Merged
merged 11 commits into from
May 3, 2024

Conversation

richrace
Copy link
Collaborator

@richrace richrace commented Apr 29, 2024

See this release from React: https://github.com/facebook/react/releases/tag/v18.3.0

  • Documentation - N/A
  • Tests
  • Ready to be merged

mark-small and others added 6 commits November 20, 2023 20:27
The `defaultProps` has been deprecated for some time for function
components. I have gone through and updated all function components
to use Default Parameters instead. You can see the deprecation notice
at:

https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md#deprecate-defaultprops-on-function-components
Default props have been removed from functional components, but not
necessarily from styled components. Since the change I made changed
the chromatic tests, I have now reverted this single defaultProp.
@richrace richrace marked this pull request as ready for review April 29, 2024 17:25
@richrace richrace marked this pull request as draft April 30, 2024 07:20
@richrace richrace marked this pull request as ready for review April 30, 2024 16:35
@richrace
Copy link
Collaborator Author

@penx, Could you have a look and see what you think?

I've removed all the defaultProps on the components.

@penx
Copy link
Member

penx commented May 1, 2024

2 minor bits of feedback but all good otherwise:

Thanks for the contribution!

@penx
Copy link
Member

penx commented May 1, 2024

The fixed width font has changed in some stories on Chromatic, I suspect due to differences elsewhere or within Chromatic but worth checking against the main branch to be certain.

@richrace
Copy link
Collaborator Author

richrace commented May 1, 2024

The fixed width font has changed in some stories on Chromatic, I suspect due to differences elsewhere or within Chromatic but worth checking against the main branch to be certain.

I'm not sure what I'm meant to be looking at. I've compared Chromatic to main (GitHub Pages) and my branch (local and Chromatic), and it seems consistent (apart from Chromatic not having the intros and args).

@stevesims
Copy link
Member

besides the font differences, Chromatic is also showing what looks like a margin difference on a radio button story. this PR seems to have a significantly reduced margin

@richrace
Copy link
Collaborator Author

richrace commented May 1, 2024

Interesting, I have not changed any of the stylings. 😕

@penx
Copy link
Member

penx commented May 1, 2024

besides the font differences, Chromatic is also showing what looks like a margin difference on a radio button story. this PR seems to have a significantly reduced margin

@stevesims I think you're referring to this, which I think is also the fixed width thing, there seems to be a {} on this page, coming from something displaying in fixed width, and it has changed in height

@richrace If these stories look the same in main and this branch then I think we're good, likely due to a change with chromatic's rendering since we last approved something.

The thing to look out for is the font family and size being used for the fixed width parts of the stories above. Are you able to open the Chromatic links and see the visual diffs?

@richrace
Copy link
Collaborator Author

richrace commented May 1, 2024

Ah the "UI Tests" I can see what you mean now. I'll investigate.

@richrace
Copy link
Collaborator Author

richrace commented May 1, 2024

The {} is the same, font family is monospace and using pre tag with margin: 1em 0px

Code is the same, <code> and the font family is monospace

Bold is the same, <strong> and font family is "nta" ,Arial, sans-serif

Italics are the same, <em> and font family is "nta" ,Arial, sans-serif

So it's:

likely due to a change with chromatic's rendering since we last approved something

@richrace
Copy link
Collaborator Author

richrace commented May 2, 2024

Are you happy for me to Accept the visual changes that https://www.chromatic.com/build?appId=5ad61aab7f00090020dfdba8&number=2659 have thrown up?

@penx
Copy link
Member

penx commented May 2, 2024

Are you happy for me to Accept the visual changes that https://www.chromatic.com/build?appId=5ad61aab7f00090020dfdba8&number=2659 have thrown up?

Sure if you have access to accept? Accept the ones that are due to a difference in rendering fixed width fonts, which I think is all of them

@richrace
Copy link
Collaborator Author

richrace commented May 2, 2024

That's all done.

Just the cypress tests to run and it should be good to merge and be released.

@stevesims
Copy link
Member

@stevesims I think you're referring to this, which I think is also the fixed width thing, there seems to be a {} on this page, coming from something displaying in fixed width, and it has changed in height

yes - that was the thing. if you look at the "1 up" view then there's a green line shown right at the bottom

having taken a closer look directly checking out the two respective storybooks for each branch being compared, I can see no difference - they are the same height

this therefore seems to be another odd chromatic rendering issue, like the minor font rendering differences the other stories are showing - so it feels safe to ignore. 😀

@richrace
Copy link
Collaborator Author

richrace commented May 2, 2024

On my fork, the Cypress tests run (and pass), but they don't seem to get run on the PR. What am I missing here?

Edit: See the commit below b799832

@richrace richrace enabled auto-merge (squash) May 2, 2024 14:28
@richrace richrace disabled auto-merge May 2, 2024 14:28
@richrace richrace changed the title Default params Remove defaultProps to support React 18.3.0 May 2, 2024
@richrace
Copy link
Collaborator Author

richrace commented May 2, 2024

This should be all good to go.

@penx penx merged commit 119eb47 into govuk-react:main May 3, 2024
10 checks passed
@penx
Copy link
Member

penx commented May 3, 2024

@richrace thanks!

Do you want to attempt a release and see how far you get?

https://github.com/govuk-react/govuk-react/blob/main/CONTRIBUTING.md#releasing

@penx penx mentioned this pull request May 7, 2024
@richrace richrace deleted the default-params branch May 21, 2024 16:20
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

Successfully merging this pull request may close these issues.

None yet

5 participants