From 16d053d592673dd5565d85109f259371b23f87e8 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Sat, 6 May 2023 20:39:08 -0400 Subject: [PATCH] Add useFormStatus to server rendering stub (#26788) This was an oversight when I set up the hook in #26719. --- packages/react-dom/server-rendering-stub.js | 1 + .../react-dom-server-rendering-stub-test.js | 12 ++++++++++++ .../src/server/ReactDOMServerRenderingStub.js | 1 + 3 files changed, 14 insertions(+) diff --git a/packages/react-dom/server-rendering-stub.js b/packages/react-dom/server-rendering-stub.js index 6d28ee413b3cf..33d404cd7605f 100644 --- a/packages/react-dom/server-rendering-stub.js +++ b/packages/react-dom/server-rendering-stub.js @@ -22,4 +22,5 @@ export { preconnect, preload, preinit, + experimental_useFormStatus, } from './src/server/ReactDOMServerRenderingStub'; diff --git a/packages/react-dom/src/__tests__/react-dom-server-rendering-stub-test.js b/packages/react-dom/src/__tests__/react-dom-server-rendering-stub-test.js index 8840a4f61a22a..2943ddb6054f4 100644 --- a/packages/react-dom/src/__tests__/react-dom-server-rendering-stub-test.js +++ b/packages/react-dom/src/__tests__/react-dom-server-rendering-stub-test.js @@ -81,4 +81,16 @@ describe('react-dom-server-rendering-stub', () => { ); expect(x).toBe(false); }); + + // @gate enableFormActions + // @gate enableAsyncActions + it('exports experimental_useFormStatus', async () => { + function App() { + const {pending} = ReactDOM.experimental_useFormStatus(); + return 'Pending: ' + pending; + } + + const result = await ReactDOMFizzServer.renderToStaticMarkup(); + expect(result).toEqual('Pending: false'); + }); }); diff --git a/packages/react-dom/src/server/ReactDOMServerRenderingStub.js b/packages/react-dom/src/server/ReactDOMServerRenderingStub.js index 29b53d5c51704..ecb46bec0c4a2 100644 --- a/packages/react-dom/src/server/ReactDOMServerRenderingStub.js +++ b/packages/react-dom/src/server/ReactDOMServerRenderingStub.js @@ -8,6 +8,7 @@ */ export {preinit, preload, preconnect, prefetchDNS} from '../ReactDOMFloat'; +export {useFormStatus as experimental_useFormStatus} from 'react-dom-bindings/src/shared/ReactDOMFormActions'; export function createPortal() { throw new Error(