Fix auto-id build for backwards compatibility with React <18#961
Open
Fix auto-id build for backwards compatibility with React <18#961
auto-id build for backwards compatibility with React <18#961Conversation
emmenko
commented
Aug 28, 2022
Comment on lines
+15
to
+16
| # storybook | ||
| /playground/storybook-static |
Author
There was a problem hiding this comment.
Artifact of building Storybook locally.
emmenko
commented
Aug 28, 2022
Comment on lines
-90
to
-97
| // TODO: Remove error flag when updating internal deps to React 18. None of | ||
| // our tricks will play well with concurrent rendering anyway. | ||
| // @ts-expect-error | ||
| if (typeof React.useId === "function") { | ||
| // @ts-expect-error | ||
| let id = React.useId(providedId); | ||
| return providedId != null ? providedId : id; | ||
| } |
Author
There was a problem hiding this comment.
This is what is causing the problem. I suggest to simply remove this once only React >=18 is supported.
There was a problem hiding this comment.
Is there no way to rewrite this to keep your build process from showing a warning? I think that would be preferable.
emmenko
commented
Aug 28, 2022
| @@ -1,5 +1,5 @@ | |||
| import * as React from "react"; | |||
| import WindowSize from "@reach/window-size"; | |||
| import { WindowSize } from "@reach/window-size"; | |||
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit a8aed9e:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #921
TL;DR: the bundle of
@reach/auto-idcontains an import ofuseIdfromreact. For versions of React <18 this import does not exist, causing an error when this package is used.This can also be seen in the Storybook playground build output (although Storybook shows a warning)
To fix that, I suggest to remove that code and change the implementation once React >=18 is supported.
I also fixed another import issue shown by Storybook
Thank you for contributing to Reach UI! Please fill in this template before submitting your PR to help us process your request more quickly.
yarn test).yarn start).This pull request:
If creating a new package:
examplesdirectorysrcdirectory with anindex.tsxentry filestyle.cssfile (if needed by the new package)