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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

type fixes for React 18 #20575

Merged
merged 1 commit into from
Oct 13, 2023
Merged

type fixes for React 18 #20575

merged 1 commit into from
Oct 13, 2023

Conversation

Rugvip
Copy link
Member

@Rugvip Rugvip commented Oct 12, 2023

馃Ч, couple of fixes to make types work for both React 17 and 18

Work towards #12252

adding changesets once things build 馃槄

@github-actions github-actions bot added area:catalog Related to the Catalog Project Area area:techdocs Related to the TechDocs Project Area search Things related to Search area:scaffolder Everything and all things related to the scaffolder project area area:discoverability Related to the Discoverability Project Area labels Oct 12, 2023
@backstage-goalie

This comment was marked as resolved.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 12, 2023

Uffizzi Preview deployment-38389 was deleted.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
@Rugvip
Copy link
Member Author

Rugvip commented Oct 13, 2023

Alright, changesets added for all changes that aren't just internal types, this should be ready to go now

Copy link
Member

@tudi2d tudi2d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Some comments & questions out of curiosity :)

@@ -249,7 +249,7 @@ export interface DependencyGraphProps<NodeData, EdgeData>
acyclicer?: 'greedy';
align?: DependencyGraphTypes.Alignment;
curve?: 'curveStepBefore' | 'curveMonotoneX';
defs?: SVGDefsElement | SVGDefsElement[];
defs?: JSX.Element | JSX.Element[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering a bit about this as it seems to make a specific type more general. Did you use this to prevent a ... cannot be used as a JSX component error? Saw this comment, which might be helpful: software-mansion/react-native-svg#1741 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah SVGDefsElement is just a wildly wrong type here, it's an actual DOM element, which you can't use in React in the way that the below code does. You also can't narrow down element types with TypeScript, so JSX.Element + docs it is x)

@@ -181,7 +181,9 @@ export const FileExplorer = () => {
}
if (!value) {
return (
<Alert severity="warning">No code coverage found for ${entity}</Alert>
<Alert severity="warning">
No code coverage found for {humanizeEntityRef(entity)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL this functions exists 馃帀

Comment on lines +201 to +203
{({ results }) => (
<>
{results.map((result, index) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you maybe explain this change a bit more? A bit confused why the wrapping Fragment is required :/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The (resultSet: SearchResultSet) => JSX.Element type doesn't allow for JSX.Element[], so we wrap it in a fragment to return just a single element.

Might be worth changing SearchResultProps instead though, @camilaibs? 馃榿

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought I'd rather make the type change in a followup, trying to keep actual changes in this one to a minimum 馃槄

return (
<SearchBarBase
value={query}
onSubmit={handleSubmit}
onChange={handleChange}
onChange={setQuery}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice cleanup! 馃挭

@Rugvip Rugvip merged commit e1bf2a5 into master Oct 13, 2023
45 checks passed
@Rugvip Rugvip deleted the rugvip/react18 branch October 13, 2023 14:03
@github-actions
Copy link
Contributor

Thank you for contributing to Backstage! The changes in this pull request will be part of the 1.19.0 release, scheduled for Tue, 17 Oct 2023.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:catalog Related to the Catalog Project Area area:discoverability Related to the Discoverability Project Area area:scaffolder Everything and all things related to the scaffolder project area area:techdocs Related to the TechDocs Project Area search Things related to Search
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants