diff --git a/.changeset/smooth-teeth-send.md b/.changeset/smooth-teeth-send.md new file mode 100644 index 000000000..51f16beee --- /dev/null +++ b/.changeset/smooth-teeth-send.md @@ -0,0 +1,5 @@ +--- +'@tanstack/react-form': patch +--- + +Fix compile error with webpack when using react v17 diff --git a/packages/react-form/src/useFormId.ts b/packages/react-form/src/useFormId.ts index 4b78db9b9..575478201 100644 --- a/packages/react-form/src/useFormId.ts +++ b/packages/react-form/src/useFormId.ts @@ -1,6 +1,11 @@ import * as React from 'react' import { useUUID } from './useUUID' -/** React 17 does not have the useId hook, so we use a random uuid as a fallback. */ +/** + * React 17 does not have the useId hook, so we use a random uuid as a fallback. + * This is needed to avoid bundlers trying to import non-existing export. + * Read more: https://github.com/webpack/webpack/issues/14814 + */ +const _React = React export const useFormId = - React.version.split('.')[0] === '17' ? useUUID : React.useId + React.version.split('.')[0] === '17' ? useUUID : _React.useId