Closed jorgeepc closed 1 year ago
I don't think we should implement webpack workarounds when the problem is useId
is only supported in React 18. I think we should try find an alternative to this hook and remove it entirely. This ensures we have support for React < 18.
Others also have the same issue as we do: https://github.com/roginfarrer/collapsed/issues/117
If this works with R17 and R18 we should merge it, and remove it once webpack or React fix the issue upstream.
If it doesn't work, replace useId
with a random string generator (potentially using setState), which has the same effect.
What about outsourcing the dirty work? @over-ui/use-id
also uses a webpack workaround (https://github.com/over-ui/unstyled/blob/main/packages/useId/src/useId.ts; the .toString()
serves the same purpose as my workaround and is much nicer IMO) with a similar fallback to ours. Or should we rather keep it under our control so we can decide when to change back?
After a brief chat with @aeneasr, we agreed to just keep it in our code. I switched to the other workaround anyways since it has better runtime. This version has been tested without npm link
(I manually copied the build output into node_modules
) in React 17 & 18 projects and work as expected.
Hey @LBBO thank you for the priority with this. I tested the new release 0.0.1-beta.9
and it's working as expected. 🙌
This PR fixes a compile error in projects using
React 17
. The change introduced in #113 implements unique IDs for components assuming that theuseId
react hook will be available. The proposed fix changes the import format to exclude theuseId
import from the build.Related Issue or Design Document
See conversation in #120
Sample dependencies to reproduce the issue:
Checklist
Further comments