Spaces:
Sleeping
Sleeping
Download frontend/node_modules/@mui/utils/modern/useId/useId.js from sepidnes/pythonic-rag-FastAPIReact: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/spaces/sepidnes/pythonic-rag-FastAPIReact/resolve/c9f908872ebbec3c4fa1392419c0f6cd3750ddb3/frontend/node_modules/%40mui/utils/modern/useId/useId.js
- Command line
-
hf download hf://spaces/sepidnes/pythonic-rag-FastAPIReact@c9f908872ebbec3c4fa1392419c0f6cd3750ddb3/frontend/node_modules/@mui/utils/modern/useId/useId.js
-
curl -L -o useId.js https://huggingface.co/spaces/sepidnes/pythonic-rag-FastAPIReact/resolve/c9f908872ebbec3c4fa1392419c0f6cd3750ddb3/frontend/node_modules/%40mui/utils/modern/useId/useId.js
1.23 kB
| 'use client'; | |
| import * as React from 'react'; | |
| let globalId = 0; | |
| function useGlobalId(idOverride) { | |
| const [defaultId, setDefaultId] = React.useState(idOverride); | |
| const id = idOverride || defaultId; | |
| React.useEffect(() => { | |
| if (defaultId == null) { | |
| // Fallback to this default id when possible. | |
| // Use the incrementing value for client-side rendering only. | |
| // We can't use it server-side. | |
| // If you want to use random values please consider the Birthday Problem: https://en.wikipedia.org/wiki/Birthday_problem | |
| globalId += 1; | |
| setDefaultId(`mui-${globalId}`); | |
| } | |
| }, [defaultId]); | |
| return id; | |
| } | |
| // downstream bundlers may remove unnecessary concatenation, but won't remove toString call -- Workaround for https://github.com/webpack/webpack/issues/14814 | |
| const maybeReactUseId = React['useId'.toString()]; | |
| /** | |
| * | |
| * @example <div id={useId()} /> | |
| * @param idOverride | |
| * @returns {string} | |
| */ | |
| export default function useId(idOverride) { | |
| if (maybeReactUseId !== undefined) { | |
| const reactId = maybeReactUseId(); | |
| return idOverride ?? reactId; | |
| } | |
| // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime. | |
| return useGlobalId(idOverride); | |
| } |