MCPcopy
hub / github.com/facebook/react / useId

Function useId

packages/react-server/src/ReactFizzHooks.js:734–747  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

732}
733
734function useId(): string {
735 const task: Task = (currentlyRenderingTask: any);
736 const treeId = getTreeId(task.treeContext);
737
738 const resumableState = currentResumableState;
739 if (resumableState === null) {
740 throw new Error(
741 'Invalid hook call. Hooks can only be called inside of the body of a function component.',
742 );
743 }
744
745 const localId = localIdCounter++;
746 return makeId(resumableState, treeId, localId);
747}
748
749function use<T>(usable: Usable<T>): T {
750 if (usable !== null && typeof usable === 'object') {

Callers 1

ReactFiberHooks.jsFile · 0.50

Calls 2

getTreeIdFunction · 0.90
makeIdFunction · 0.90

Tested by

no test coverage detected