-
-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(multishift): remove
@reach/auto-id
(#2006)
- Loading branch information
Showing
5 changed files
with
41 additions
and
23 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,5 @@ | ||
--- | ||
'multishift': patch | ||
--- | ||
|
||
Remove maintained `@reach/auto-id` from dependencies. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import * as React from 'react'; | ||
|
||
const useIsomorphicLayoutEffect = | ||
typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect; | ||
|
||
let count = 0; | ||
const genId = () => `multishift-id-${count++}`; | ||
|
||
let serverHandoffComplete = false; | ||
|
||
function useReact17Id() { | ||
const [id, setId] = React.useState(() => (serverHandoffComplete ? genId() : undefined)); | ||
|
||
useIsomorphicLayoutEffect(() => { | ||
if (id == null) { | ||
setId(genId()); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
React.useEffect(() => { | ||
if (!serverHandoffComplete) { | ||
serverHandoffComplete = true; | ||
} | ||
}, []); | ||
|
||
return id; | ||
} | ||
|
||
// `toString()` prevents bundlers from trying to `import { useId } from 'react'` | ||
const useReact18Id = (React as any)['useId'.toString()] as () => string; | ||
|
||
const useId = useReact18Id || useReact17Id; | ||
|
||
export { useId }; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
48ee2c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://remirror.io as production
🚀 Deployed on https://640ba86fd8fc9d07cb28ce55--remirror.netlify.app