Skip to content

Remove experimental useOpaqueIdentifier API #22672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions packages/react-art/src/ReactARTHostConfig.js
Original file line number Diff line number Diff line change
@@ -436,24 +436,6 @@ export function getInstanceFromNode(node) {
throw new Error('Not implemented.');
}

export function isOpaqueHydratingObject(value: mixed): boolean {
throw new Error('Not implemented.');
}

export function makeOpaqueHydratingObject(
attemptToReadValue: () => void,
): OpaqueIDType {
throw new Error('Not implemented.');
}

export function makeClientId(): OpaqueIDType {
throw new Error('Not implemented.');
}

export function makeClientIdInDEV(warnOnAccessInDEV: () => void): OpaqueIDType {
throw new Error('Not implemented.');
}

export function beforeActiveInstanceBlur(internalInstanceHandle: Object) {
// noop
}
26 changes: 0 additions & 26 deletions packages/react-debug-tools/src/ReactDebugHooks.js
Original file line number Diff line number Diff line change
@@ -18,13 +18,9 @@ import type {
Fiber,
Dispatcher as DispatcherType,
} from 'react-reconciler/src/ReactInternalTypes';
import type {OpaqueIDType} from 'react-reconciler/src/ReactFiberHostConfig';

import {NoMode} from 'react-reconciler/src/ReactTypeOfMode';

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

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

let currentFiber: Fiber | null = null;

type Hook = {
memoizedState: any,
next: Hook | null,
@@ -324,23 +318,6 @@ function useDeferredValue<T>(value: T): T {
return value;
}

function useOpaqueIdentifier(): OpaqueIDType | void {
const hook = nextHook(); // State
if (currentFiber && currentFiber.mode === NoMode) {
nextHook(); // Effect
}
let value = hook === null ? undefined : hook.memoizedState;
if (value && value.$$typeof === REACT_OPAQUE_ID_TYPE) {
value = undefined;
}
hookLog.push({
primitive: 'OpaqueIdentifier',
stackError: new Error(),
value,
});
return value;
}

function useId(): string {
const hook = nextHook();
const id = hook !== null ? hook.memoizedState : '';
@@ -371,7 +348,6 @@ const Dispatcher: DispatcherType = {
useMutableSource,
useSyncExternalStore,
useDeferredValue,
useOpaqueIdentifier,
useId,
};

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

currentFiber = fiber;

if (
fiber.tag !== FunctionComponent &&
fiber.tag !== SimpleMemoComponent &&
Original file line number Diff line number Diff line change
@@ -598,64 +598,6 @@ describe('ReactHooksInspectionIntegration', () => {
]);
});

it('should support composite useOpaqueIdentifier hook', () => {
function Foo(props) {
const id = React.unstable_useOpaqueIdentifier();
const [state] = React.useState(() => 'hello', []);
return <div id={id}>{state}</div>;
}

const renderer = ReactTestRenderer.create(<Foo />);
const childFiber = renderer.root.findByType(Foo)._currentFiber();
const tree = ReactDebugTools.inspectHooksOfFiber(childFiber);

expect(tree.length).toEqual(2);

expect(tree[0].id).toEqual(0);
expect(tree[0].isStateEditable).toEqual(false);
expect(tree[0].name).toEqual('OpaqueIdentifier');
expect(String(tree[0].value).startsWith('c_')).toBe(true);

expect(tree[1]).toEqual({
id: 1,
isStateEditable: true,
name: 'State',
value: 'hello',
subHooks: [],
});
});

it('should support composite useOpaqueIdentifier hook in concurrent mode', () => {
function Foo(props) {
const id = React.unstable_useOpaqueIdentifier();
const [state] = React.useState('hello');
return <div id={id}>{state}</div>;
}

const renderer = ReactTestRenderer.create(<Foo />, {
unstable_isConcurrent: true,
});
expect(Scheduler).toFlushWithoutYielding();

const childFiber = renderer.root.findByType(Foo)._currentFiber();
const tree = ReactDebugTools.inspectHooksOfFiber(childFiber);

expect(tree.length).toEqual(2);

expect(tree[0].id).toEqual(0);
expect(tree[0].isStateEditable).toEqual(false);
expect(tree[0].name).toEqual('OpaqueIdentifier');
expect(String(tree[0].value).startsWith('c_')).toBe(true);

expect(tree[1]).toEqual({
id: 1,
isStateEditable: true,
name: 'State',
value: 'hello',
subHooks: [],
});
});

it('should support useId hook', () => {
function Foo(props) {
const id = React.unstable_useId();
3 changes: 0 additions & 3 deletions packages/react-devtools-shared/src/backend/ReactSymbols.js
Original file line number Diff line number Diff line change
@@ -40,9 +40,6 @@ export const LAZY_SYMBOL_STRING = 'Symbol(react.lazy)';
export const MEMO_NUMBER = 0xead3;
export const MEMO_SYMBOL_STRING = 'Symbol(react.memo)';

export const OPAQUE_ID_NUMBER = 0xeae0;
export const OPAQUE_ID_SYMBOL_STRING = 'Symbol(react.opaque.id)';

export const PORTAL_NUMBER = 0xeaca;
export const PORTAL_SYMBOL_STRING = 'Symbol(react.portal)';

Loading