|
Last change
on this file since ba17441 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
663 bytes
|
| Line | |
|---|
| 1 | var _ref;
|
|---|
| 2 | import * as React from 'react';
|
|---|
| 3 | import { uniqueId } from './DataUtils';
|
|---|
| 4 |
|
|---|
| 5 | /**
|
|---|
| 6 | * Fallback for React.useId() for versions prior to React 18.
|
|---|
| 7 | * Generates a unique ID using a simple counter and a prefix.
|
|---|
| 8 | *
|
|---|
| 9 | * @returns A unique ID that remains consistent across renders.
|
|---|
| 10 | */
|
|---|
| 11 | export var useIdFallback = () => {
|
|---|
| 12 | var [id] = React.useState(() => uniqueId('uid-'));
|
|---|
| 13 | return id;
|
|---|
| 14 | };
|
|---|
| 15 |
|
|---|
| 16 | /*
|
|---|
| 17 | * This weird syntax is used to avoid a build-time error in React 17 and earlier when building with Webpack.
|
|---|
| 18 | * See https://github.com/webpack/webpack/issues/14814
|
|---|
| 19 | */
|
|---|
| 20 | export var useId = (_ref = React['useId'.toString()]) !== null && _ref !== void 0 ? _ref : useIdFallback; |
|---|
Note:
See
TracBrowser
for help on using the repository browser.