• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SAP / ui5-webcomponents-react / 4752616003

pending completion
4752616003

Pull #4140

github

GitHub
Merge 539a382b1 into 3bc9fe146
Pull Request #4140: fix(base): mark base package as `type: module`

2622 of 3598 branches covered (72.87%)

0 of 1 new or added line in 1 file covered. (0.0%)

5087 of 5880 relevant lines covered (86.51%)

11900.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

46.15
/packages/base/src/hooks/useIsomorphicId.ts
1
import * as React from 'react';
2

3
function getRandomId() {
4
  if ('randomUUID' in crypto) {
×
5
    return crypto.randomUUID();
×
6
  }
7
  const uint32 = window.crypto.getRandomValues(new Uint32Array(1))[0];
×
8
  return uint32.toString(16);
×
9
}
10

11
const canUseUseId = 'useId' in React;
370✔
12

13
export function useIsomorphicId(): string {
23,488✔
14
  if (canUseUseId) {
23,488✔
15
    // TODO might be fixed by https://github.com/webpack/webpack/issues/14814
16
    return Reflect.get(React, 'useId')();
23,488✔
17
  }
18

19
  // eslint-disable-next-line react-hooks/rules-of-hooks
NEW
20
  const localId = React.useRef(getRandomId()); // React version never changes at runtime
×
21
  return localId.current;
×
22
}
370✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc