Skip to content
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

Remove experimental useOpaqueIdentifier API #22672

Merged
merged 1 commit into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
Expand Up @@ -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
}
Expand Down
26 changes: 0 additions & 26 deletions packages/react-debug-tools/src/ReactDebugHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 : '';
Expand Down Expand Up @@ -371,7 +348,6 @@ const Dispatcher: DispatcherType = {
useMutableSource,
useSyncExternalStore,
useDeferredValue,
useOpaqueIdentifier,
useId,
};

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

currentFiber = fiber;

if (
fiber.tag !== FunctionComponent &&
fiber.tag !== SimpleMemoComponent &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 0 additions & 3 deletions packages/react-devtools-shared/src/backend/ReactSymbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)';

Expand Down