Skip to content

Commit

Permalink
Upgrade useInsertionEffect to stable (#22589)
Browse files Browse the repository at this point in the history
@huozhi tried this out and says it's working as expected. I think we
can go ahead and move this into the stable channel, so that it is
available in the React 18 alpha releases.
  • Loading branch information
acdlite authored Oct 19, 2021
1 parent b81de86 commit 02f4115
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,8 @@ describe('ReactHooksInspectionIntegration', () => {
]);
});

// @gate experimental || www
it('should inspect the current state of all stateful hooks, including useInsertionEffect', () => {
const useInsertionEffect = React.unstable_useInsertionEffect;
const useInsertionEffect = React.useInsertionEffect;
const outsideRef = React.createRef();
function effect() {}
function Foo(props) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function initModules() {
useRef = React.useRef;
useDebugValue = React.useDebugValue;
useImperativeHandle = React.useImperativeHandle;
useInsertionEffect = React.unstable_useInsertionEffect;
useInsertionEffect = React.useInsertionEffect;
useLayoutEffect = React.useLayoutEffect;
useOpaqueIdentifier = React.unstable_useOpaqueIdentifier;
forwardRef = React.forwardRef;
Expand Down Expand Up @@ -641,7 +641,6 @@ describe('ReactDOMServerHooks', () => {
});
});
describe('useInsertionEffect', () => {
// @gate experimental || www
it('should warn when invoked during render', async () => {
function Counter() {
useInsertionEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('ReactHooksWithNoopRenderer', () => {
useState = React.useState;
useReducer = React.useReducer;
useEffect = React.useEffect;
useInsertionEffect = React.unstable_useInsertionEffect;
useInsertionEffect = React.useInsertionEffect;
useLayoutEffect = React.useLayoutEffect;
useCallback = React.useCallback;
useMemo = React.useMemo;
Expand Down Expand Up @@ -2685,7 +2685,6 @@ describe('ReactHooksWithNoopRenderer', () => {
});

describe('useInsertionEffect', () => {
// @gate experimental || www
it('fires insertion effects after snapshots on update', () => {
function CounterA(props) {
useInsertionEffect(() => {
Expand Down Expand Up @@ -2745,7 +2744,6 @@ describe('ReactHooksWithNoopRenderer', () => {
});
});

// @gate experimental || www
it('fires insertion effects before layout effects', () => {
let committedText = '(empty)';

Expand Down Expand Up @@ -2808,7 +2806,6 @@ describe('ReactHooksWithNoopRenderer', () => {
expect(Scheduler).toHaveYielded(['Destroy passive [current: 0]']);
});

// @gate experimental || www
it('force flushes passive effects before firing new insertion effects', () => {
let committedText = '(empty)';

Expand Down Expand Up @@ -2876,7 +2873,6 @@ describe('ReactHooksWithNoopRenderer', () => {
]);
});

// @gate experimental || www
it('fires all insertion effects (interleaved) before firing any layout effects', () => {
let committedA = '(empty)';
let committedB = '(empty)';
Expand Down Expand Up @@ -3043,7 +3039,6 @@ describe('ReactHooksWithNoopRenderer', () => {
});
});

// @gate experimental || www
it('assumes insertion effect destroy function is either a function or undefined', () => {
function App(props) {
useInsertionEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/index.classic.fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export {
useEffect,
useImperativeHandle,
useLayoutEffect,
unstable_useInsertionEffect,
useInsertionEffect,
useMemo,
useMutableSource,
useMutableSource as unstable_useMutableSource,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/index.experimental.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export {
useDeferredValue,
useEffect,
useImperativeHandle,
unstable_useInsertionEffect,
useInsertionEffect,
useLayoutEffect,
useMemo,
useMutableSource as unstable_useMutableSource,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export {
useDeferredValue,
useEffect,
useImperativeHandle,
unstable_useInsertionEffect,
useInsertionEffect,
useLayoutEffect,
useMemo,
useMutableSource,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/index.modern.fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export {
useDeferredValue as unstable_useDeferredValue, // TODO: Remove once call sights updated to useDeferredValue
useEffect,
useImperativeHandle,
unstable_useInsertionEffect,
useInsertionEffect,
useLayoutEffect,
useMemo,
useMutableSource,
Expand Down
1 change: 1 addition & 0 deletions packages/react/index.stable.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export {
useDeferredValue,
useEffect,
useImperativeHandle,
useInsertionEffect,
useLayoutEffect,
useMemo,
useMutableSource as unstable_useMutableSource,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/React.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export {
useEffect,
useImperativeHandle,
useDebugValue,
useInsertionEffect as unstable_useInsertionEffect,
useInsertionEffect,
useLayoutEffect,
useMemo,
useMutableSource,
Expand Down

0 comments on commit 02f4115

Please sign in to comment.