From e060c461ed8221d82528450ca3a74c89f88dd1b1 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Tue, 19 Oct 2021 16:38:41 -0400 Subject: [PATCH] Upgrade useInsertionEffect to stable @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. --- .../src/__tests__/ReactHooksInspectionIntegration-test.js | 3 +-- .../src/__tests__/ReactDOMServerIntegrationHooks-test.js | 2 +- .../src/__tests__/ReactHooksWithNoopRenderer-test.js | 7 +------ packages/react/index.classic.fb.js | 2 +- packages/react/index.experimental.js | 2 +- packages/react/index.js | 2 +- packages/react/index.modern.fb.js | 2 +- packages/react/index.stable.js | 1 + packages/react/src/React.js | 2 +- 9 files changed, 9 insertions(+), 14 deletions(-) diff --git a/packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js b/packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js index 013caecb11ba0..6937efd631572 100644 --- a/packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js +++ b/packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js @@ -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) { diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationHooks-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationHooks-test.js index daf3453314183..46d29e1822481 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationHooks-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationHooks-test.js @@ -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; diff --git a/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js b/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js index f56577e8ffea9..bcd96d732e09e 100644 --- a/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js +++ b/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js @@ -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; @@ -2685,7 +2685,6 @@ describe('ReactHooksWithNoopRenderer', () => { }); describe('useInsertionEffect', () => { - // @gate experimental || www it('fires insertion effects after snapshots on update', () => { function CounterA(props) { useInsertionEffect(() => { @@ -2745,7 +2744,6 @@ describe('ReactHooksWithNoopRenderer', () => { }); }); - // @gate experimental || www it('fires insertion effects before layout effects', () => { let committedText = '(empty)'; @@ -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)'; @@ -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)'; @@ -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(() => { diff --git a/packages/react/index.classic.fb.js b/packages/react/index.classic.fb.js index 7f8abc863157a..5335c4053a70e 100644 --- a/packages/react/index.classic.fb.js +++ b/packages/react/index.classic.fb.js @@ -48,7 +48,7 @@ export { useEffect, useImperativeHandle, useLayoutEffect, - unstable_useInsertionEffect, + useInsertionEffect, useMemo, useMutableSource, useMutableSource as unstable_useMutableSource, diff --git a/packages/react/index.experimental.js b/packages/react/index.experimental.js index a0a9bbaca216e..19490fb214c97 100644 --- a/packages/react/index.experimental.js +++ b/packages/react/index.experimental.js @@ -42,7 +42,7 @@ export { useDeferredValue, useEffect, useImperativeHandle, - unstable_useInsertionEffect, + useInsertionEffect, useLayoutEffect, useMemo, useMutableSource as unstable_useMutableSource, diff --git a/packages/react/index.js b/packages/react/index.js index 1b4552a90f5d8..b4a3bf6e11b81 100644 --- a/packages/react/index.js +++ b/packages/react/index.js @@ -67,7 +67,7 @@ export { useDeferredValue, useEffect, useImperativeHandle, - unstable_useInsertionEffect, + useInsertionEffect, useLayoutEffect, useMemo, useMutableSource, diff --git a/packages/react/index.modern.fb.js b/packages/react/index.modern.fb.js index 819d5fe90afd3..2b847d2336312 100644 --- a/packages/react/index.modern.fb.js +++ b/packages/react/index.modern.fb.js @@ -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, diff --git a/packages/react/index.stable.js b/packages/react/index.stable.js index 008875e4577e5..4e4682b8fc29f 100644 --- a/packages/react/index.stable.js +++ b/packages/react/index.stable.js @@ -36,6 +36,7 @@ export { useDeferredValue, useEffect, useImperativeHandle, + useInsertionEffect, useLayoutEffect, useMemo, useMutableSource as unstable_useMutableSource, diff --git a/packages/react/src/React.js b/packages/react/src/React.js index 541e7a35d3d3e..2246d32db662e 100644 --- a/packages/react/src/React.js +++ b/packages/react/src/React.js @@ -92,7 +92,7 @@ export { useEffect, useImperativeHandle, useDebugValue, - useInsertionEffect as unstable_useInsertionEffect, + useInsertionEffect, useLayoutEffect, useMemo, useMutableSource,