Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/smooth-teeth-send.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/react-form': patch
---

Fix compile error with webpack when using react v17
9 changes: 7 additions & 2 deletions packages/react-form/src/useFormId.ts
Original file line number Diff line number Diff line change
@@ -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
Loading