Skip to content

Commit 75f3dde

Browse files
authored
Remove experimental useOpaqueIdentifier API (#22672)
useId is the updated version of this API.
1 parent 8c4a05b commit 75f3dde

39 files changed

+22
-1790
lines changed

packages/react-art/src/ReactARTHostConfig.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -436,24 +436,6 @@ export function getInstanceFromNode(node) {
436436
throw new Error('Not implemented.');
437437
}
438438

439-
export function isOpaqueHydratingObject(value: mixed): boolean {
440-
throw new Error('Not implemented.');
441-
}
442-
443-
export function makeOpaqueHydratingObject(
444-
attemptToReadValue: () => void,
445-
): OpaqueIDType {
446-
throw new Error('Not implemented.');
447-
}
448-
449-
export function makeClientId(): OpaqueIDType {
450-
throw new Error('Not implemented.');
451-
}
452-
453-
export function makeClientIdInDEV(warnOnAccessInDEV: () => void): OpaqueIDType {
454-
throw new Error('Not implemented.');
455-
}
456-
457439
export function beforeActiveInstanceBlur(internalInstanceHandle: Object) {
458440
// noop
459441
}

packages/react-debug-tools/src/ReactDebugHooks.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,9 @@ import type {
1818
Fiber,
1919
Dispatcher as DispatcherType,
2020
} from 'react-reconciler/src/ReactInternalTypes';
21-
import type {OpaqueIDType} from 'react-reconciler/src/ReactFiberHostConfig';
22-
23-
import {NoMode} from 'react-reconciler/src/ReactTypeOfMode';
2421

2522
import ErrorStackParser from 'error-stack-parser';
2623
import ReactSharedInternals from 'shared/ReactSharedInternals';
27-
import {REACT_OPAQUE_ID_TYPE} from 'shared/ReactSymbols';
2824
import {
2925
FunctionComponent,
3026
SimpleMemoComponent,
@@ -53,8 +49,6 @@ type Dispatch<A> = A => void;
5349

5450
let primitiveStackCache: null | Map<string, Array<any>> = null;
5551

56-
let currentFiber: Fiber | null = null;
57-
5852
type Hook = {
5953
memoizedState: any,
6054
next: Hook | null,
@@ -324,23 +318,6 @@ function useDeferredValue<T>(value: T): T {
324318
return value;
325319
}
326320

327-
function useOpaqueIdentifier(): OpaqueIDType | void {
328-
const hook = nextHook(); // State
329-
if (currentFiber && currentFiber.mode === NoMode) {
330-
nextHook(); // Effect
331-
}
332-
let value = hook === null ? undefined : hook.memoizedState;
333-
if (value && value.$$typeof === REACT_OPAQUE_ID_TYPE) {
334-
value = undefined;
335-
}
336-
hookLog.push({
337-
primitive: 'OpaqueIdentifier',
338-
stackError: new Error(),
339-
value,
340-
});
341-
return value;
342-
}
343-
344321
function useId(): string {
345322
const hook = nextHook();
346323
const id = hook !== null ? hook.memoizedState : '';
@@ -371,7 +348,6 @@ const Dispatcher: DispatcherType = {
371348
useMutableSource,
372349
useSyncExternalStore,
373350
useDeferredValue,
374-
useOpaqueIdentifier,
375351
useId,
376352
};
377353

@@ -767,8 +743,6 @@ export function inspectHooksOfFiber(
767743
currentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
768744
}
769745

770-
currentFiber = fiber;
771-
772746
if (
773747
fiber.tag !== FunctionComponent &&
774748
fiber.tag !== SimpleMemoComponent &&

packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -598,64 +598,6 @@ describe('ReactHooksInspectionIntegration', () => {
598598
]);
599599
});
600600

601-
it('should support composite useOpaqueIdentifier hook', () => {
602-
function Foo(props) {
603-
const id = React.unstable_useOpaqueIdentifier();
604-
const [state] = React.useState(() => 'hello', []);
605-
return <div id={id}>{state}</div>;
606-
}
607-
608-
const renderer = ReactTestRenderer.create(<Foo />);
609-
const childFiber = renderer.root.findByType(Foo)._currentFiber();
610-
const tree = ReactDebugTools.inspectHooksOfFiber(childFiber);
611-
612-
expect(tree.length).toEqual(2);
613-
614-
expect(tree[0].id).toEqual(0);
615-
expect(tree[0].isStateEditable).toEqual(false);
616-
expect(tree[0].name).toEqual('OpaqueIdentifier');
617-
expect(String(tree[0].value).startsWith('c_')).toBe(true);
618-
619-
expect(tree[1]).toEqual({
620-
id: 1,
621-
isStateEditable: true,
622-
name: 'State',
623-
value: 'hello',
624-
subHooks: [],
625-
});
626-
});
627-
628-
it('should support composite useOpaqueIdentifier hook in concurrent mode', () => {
629-
function Foo(props) {
630-
const id = React.unstable_useOpaqueIdentifier();
631-
const [state] = React.useState('hello');
632-
return <div id={id}>{state}</div>;
633-
}
634-
635-
const renderer = ReactTestRenderer.create(<Foo />, {
636-
unstable_isConcurrent: true,
637-
});
638-
expect(Scheduler).toFlushWithoutYielding();
639-
640-
const childFiber = renderer.root.findByType(Foo)._currentFiber();
641-
const tree = ReactDebugTools.inspectHooksOfFiber(childFiber);
642-
643-
expect(tree.length).toEqual(2);
644-
645-
expect(tree[0].id).toEqual(0);
646-
expect(tree[0].isStateEditable).toEqual(false);
647-
expect(tree[0].name).toEqual('OpaqueIdentifier');
648-
expect(String(tree[0].value).startsWith('c_')).toBe(true);
649-
650-
expect(tree[1]).toEqual({
651-
id: 1,
652-
isStateEditable: true,
653-
name: 'State',
654-
value: 'hello',
655-
subHooks: [],
656-
});
657-
});
658-
659601
it('should support useId hook', () => {
660602
function Foo(props) {
661603
const id = React.unstable_useId();

packages/react-devtools-shared/src/backend/ReactSymbols.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ export const LAZY_SYMBOL_STRING = 'Symbol(react.lazy)';
4040
export const MEMO_NUMBER = 0xead3;
4141
export const MEMO_SYMBOL_STRING = 'Symbol(react.memo)';
4242

43-
export const OPAQUE_ID_NUMBER = 0xeae0;
44-
export const OPAQUE_ID_SYMBOL_STRING = 'Symbol(react.opaque.id)';
45-
4643
export const PORTAL_NUMBER = 0xeaca;
4744
export const PORTAL_SYMBOL_STRING = 'Symbol(react.portal)';
4845

0 commit comments

Comments
 (0)