Skip to content

Commit 815042f

Browse files
committed
changed export name to unstable_useOpaqueIdentifier
1 parent 2d9cb27 commit 815042f

File tree

7 files changed

+85
-85
lines changed

7 files changed

+85
-85
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ describe('ReactHooksInspectionIntegration', () => {
425425

426426
it('should support composite useOpaqueIdentifier hook', () => {
427427
function Foo(props) {
428-
const id = React.useOpaqueIdentifier();
428+
const id = React.unstable_useOpaqueIdentifier();
429429
const [state] = React.useState(() => 'hello', []);
430430
return <div id={id}>{state}</div>;
431431
}
@@ -452,7 +452,7 @@ describe('ReactHooksInspectionIntegration', () => {
452452

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

packages/react-dom/src/__tests__/ReactDOMServerIntegrationHooks-test.internal.js

+78-78
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function initModules() {
5757
useDebugValue = React.useDebugValue;
5858
useImperativeHandle = React.useImperativeHandle;
5959
useLayoutEffect = React.useLayoutEffect;
60-
useOpaqueIdentifier = React.useOpaqueIdentifier;
60+
useOpaqueIdentifier = React.unstable_useOpaqueIdentifier;
6161
forwardRef = React.forwardRef;
6262

6363
yieldedValues = [];
@@ -1645,99 +1645,99 @@ describe('ReactDOMServerHooks', () => {
16451645
'Do not read the value directly.',
16461646
]);
16471647
});
1648-
});
16491648

1650-
it('useOpaqueIdentifier throws if you try to add the result as a number in a child component wrapped in a Suspense', async () => {
1651-
function Child({appId}) {
1652-
return <div aria-labelledby={+appId} />;
1653-
}
1654-
function App() {
1655-
const [show] = useState(false);
1656-
const id = useOpaqueIdentifier();
1657-
return (
1658-
<React.Suspense fallback={null}>
1659-
{show && <div id={id} />}
1660-
<Child appId={id} />
1661-
</React.Suspense>
1662-
);
1663-
}
1649+
it('useOpaqueIdentifier throws if you try to add the result as a number in a child component wrapped in a Suspense', async () => {
1650+
function Child({appId}) {
1651+
return <div aria-labelledby={+appId} />;
1652+
}
1653+
function App() {
1654+
const [show] = useState(false);
1655+
const id = useOpaqueIdentifier();
1656+
return (
1657+
<React.Suspense fallback={null}>
1658+
{show && <div id={id} />}
1659+
<Child appId={id} />
1660+
</React.Suspense>
1661+
);
1662+
}
16641663

1665-
const container = document.createElement('div');
1666-
document.body.appendChild(container);
1664+
const container = document.createElement('div');
1665+
document.body.appendChild(container);
16671666

1668-
container.innerHTML = ReactDOMServer.renderToString(<App />);
1667+
container.innerHTML = ReactDOMServer.renderToString(<App />);
16691668

1670-
ReactDOM.createRoot(container, {hydrate: true}).render(<App />);
1669+
ReactDOM.createRoot(container, {hydrate: true}).render(<App />);
16711670

1672-
expect(() =>
1673-
expect(() => Scheduler.unstable_flushAll()).toThrow(
1671+
expect(() =>
1672+
expect(() => Scheduler.unstable_flushAll()).toThrow(
1673+
'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1674+
'Do not read the value directly.',
1675+
),
1676+
).toErrorDev([
16741677
'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
16751678
'Do not read the value directly.',
1676-
),
1677-
).toErrorDev([
1678-
'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1679-
'Do not read the value directly.',
1680-
]);
1681-
});
1679+
]);
1680+
});
16821681

1683-
it('useOpaqueIdentifier with two opaque identifiers on the same page', () => {
1684-
let _setShow;
1682+
it('useOpaqueIdentifier with two opaque identifiers on the same page', () => {
1683+
let _setShow;
16851684

1686-
function App() {
1687-
const id1 = useOpaqueIdentifier();
1688-
const id2 = useOpaqueIdentifier();
1689-
const [show, setShow] = useState(true);
1690-
_setShow = setShow;
1685+
function App() {
1686+
const id1 = useOpaqueIdentifier();
1687+
const id2 = useOpaqueIdentifier();
1688+
const [show, setShow] = useState(true);
1689+
_setShow = setShow;
16911690

1692-
return (
1693-
<div>
1694-
<React.Suspense fallback={null}>
1695-
{show ? (
1696-
<span id={id1}>{'Child'}</span>
1697-
) : (
1698-
<span id={id2}>{'Child'}</span>
1699-
)}
1700-
</React.Suspense>
1701-
<span aria-labelledby={id1}>{'test'}</span>
1702-
</div>
1703-
);
1704-
}
1691+
return (
1692+
<div>
1693+
<React.Suspense fallback={null}>
1694+
{show ? (
1695+
<span id={id1}>{'Child'}</span>
1696+
) : (
1697+
<span id={id2}>{'Child'}</span>
1698+
)}
1699+
</React.Suspense>
1700+
<span aria-labelledby={id1}>{'test'}</span>
1701+
</div>
1702+
);
1703+
}
17051704

1706-
const container = document.createElement('div');
1707-
document.body.appendChild(container);
1705+
const container = document.createElement('div');
1706+
document.body.appendChild(container);
17081707

1709-
container.innerHTML = ReactDOMServer.renderToString(<App />);
1708+
container.innerHTML = ReactDOMServer.renderToString(<App />);
17101709

1711-
const serverID = container
1712-
.getElementsByTagName('span')[0]
1713-
.getAttribute('id');
1714-
expect(serverID).not.toBeNull();
1715-
expect(
1716-
container
1717-
.getElementsByTagName('span')[1]
1718-
.getAttribute('aria-labelledby'),
1719-
).toEqual(serverID);
1710+
const serverID = container
1711+
.getElementsByTagName('span')[0]
1712+
.getAttribute('id');
1713+
expect(serverID).not.toBeNull();
1714+
expect(
1715+
container
1716+
.getElementsByTagName('span')[1]
1717+
.getAttribute('aria-labelledby'),
1718+
).toEqual(serverID);
17201719

1721-
ReactDOM.createRoot(container, {hydrate: true}).render(<App />);
1722-
jest.runAllTimers();
1723-
expect(Scheduler).toHaveYielded([]);
1724-
expect(Scheduler).toFlushAndYield([]);
1720+
ReactDOM.createRoot(container, {hydrate: true}).render(<App />);
1721+
jest.runAllTimers();
1722+
expect(Scheduler).toHaveYielded([]);
1723+
expect(Scheduler).toFlushAndYield([]);
17251724

1726-
ReactTestUtils.act(() => {
1727-
_setShow(false);
1728-
});
1725+
ReactTestUtils.act(() => {
1726+
_setShow(false);
1727+
});
17291728

1730-
expect(
1731-
container
1732-
.getElementsByTagName('span')[1]
1733-
.getAttribute('aria-labelledby'),
1734-
).toEqual(serverID);
1735-
expect(
1736-
container.getElementsByTagName('span')[0].getAttribute('id'),
1737-
).not.toEqual(serverID);
1738-
expect(
1739-
container.getElementsByTagName('span')[0].getAttribute('id'),
1740-
).not.toBeNull();
1729+
expect(
1730+
container
1731+
.getElementsByTagName('span')[1]
1732+
.getAttribute('aria-labelledby'),
1733+
).toEqual(serverID);
1734+
expect(
1735+
container.getElementsByTagName('span')[0].getAttribute('id'),
1736+
).not.toEqual(serverID);
1737+
expect(
1738+
container.getElementsByTagName('span')[0].getAttribute('id'),
1739+
).not.toBeNull();
1740+
});
17411741
});
17421742
}
17431743
});

packages/react/index.classic.fb.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ export {
5050
DEPRECATED_createResponder,
5151
// enableScopeAPI
5252
unstable_createScope,
53-
useOpaqueIdentifier,
53+
unstable_useOpaqueIdentifier,
5454
} from './src/React';
5555
export {jsx, jsxs, jsxDEV} from './src/jsx/ReactJSX';

packages/react/index.experimental.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ export {
4545
unstable_withSuspenseConfig,
4646
// enableBlocksAPI
4747
block,
48-
useOpaqueIdentifier,
48+
unstable_useOpaqueIdentifier,
4949
} from './src/React';

packages/react/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ export {
7272
SuspenseList,
7373
unstable_withSuspenseConfig,
7474
block,
75-
useOpaqueIdentifier,
7675
DEPRECATED_useResponder,
7776
DEPRECATED_createResponder,
7877
unstable_createFundamental,
7978
unstable_createScope,
79+
unstable_useOpaqueIdentifier,
8080
} from './src/React';

packages/react/index.modern.fb.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ export {
4949
DEPRECATED_createResponder,
5050
// enableScopeAPI
5151
unstable_createScope,
52-
useOpaqueIdentifier,
52+
unstable_useOpaqueIdentifier,
5353
} from './src/React';
5454
export {jsx, jsxs, jsxDEV} from './src/jsx/ReactJSX';

packages/react/src/React.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,5 @@ export {
118118
createFundamental as unstable_createFundamental,
119119
// enableScopeAPI
120120
createScope as unstable_createScope,
121-
useOpaqueIdentifier,
121+
useOpaqueIdentifier as unstable_useOpaqueIdentifier,
122122
};

0 commit comments

Comments
 (0)