Skip to content

Commit

Permalink
Further obfuscate reference to React.useId
Browse files Browse the repository at this point in the history
Use technique from this comment: mui/material-ui#41190 (comment) to further obfuscate reference to `React.useId` which causes issue when using `react-resizable-panels` with React <18 and `esbuild` > 0.19.5.

Fixes #381
  • Loading branch information
Niels Widger authored Jul 31, 2024
1 parent ba73ac7 commit 97df604
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/react-resizable-panels/src/vendor/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const {
useState,
} = React;

// `toString()` prevents bundlers from trying to `import { useId } from 'react'`
const useId = (React as any)["useId".toString()] as () => string;
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
const useId = (React as any)[`useId${Math.random()}`.slice(0, 5)] as () => string;

const useLayoutEffect_do_not_use_directly = useLayoutEffect;

Expand Down

0 comments on commit 97df604

Please sign in to comment.