Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

useFormId.ts

11 lines403 Bytes

1import * as React from 'react'
2import { useUUID } from './useUUID'
3​
4/**
5 * React 17 does not have the useId hook, so we use a random uuid as a fallback.
6 * This is needed to avoid bundlers trying to import non-existing export.
7 * Read more: https://github.com/webpack/webpack/issues/14814
8 */
9const _React = React
10export const useFormId =
11 React.version.split('.')[0] === '17' ? useUUID : _React.useId