diff --git a/packages/react-client/src/forks/ReactFlightClientConfig.markup.js b/packages/react-client/src/forks/ReactFlightClientConfig.markup.js index b8002483d81aa..a90acefccba39 100644 --- a/packages/react-client/src/forks/ReactFlightClientConfig.markup.js +++ b/packages/react-client/src/forks/ReactFlightClientConfig.markup.js @@ -25,7 +25,7 @@ export function prepareDestinationForModule( metadata: ClientReferenceMetadata, ) { throw new Error( - 'renderToMarkup should not have emitted Client References. This is a bug in React.', + 'renderToHTML should not have emitted Client References. This is a bug in React.', ); } @@ -34,7 +34,7 @@ export function resolveClientReference( metadata: ClientReferenceMetadata, ): ClientReference { throw new Error( - 'renderToMarkup should not have emitted Client References. This is a bug in React.', + 'renderToHTML should not have emitted Client References. This is a bug in React.', ); } @@ -43,7 +43,7 @@ export function resolveServerReference( id: ServerReferenceId, ): ClientReference { throw new Error( - 'renderToMarkup should not have emitted Server References. This is a bug in React.', + 'renderToHTML should not have emitted Server References. This is a bug in React.', ); } @@ -55,7 +55,7 @@ export function preloadModule( export function requireModule(metadata: ClientReference): T { throw new Error( - 'renderToMarkup should not have emitted Client References. This is a bug in React.', + 'renderToHTML should not have emitted Client References. This is a bug in React.', ); } diff --git a/packages/react-markup/README.md b/packages/react-markup/README.md index 0498648303e8a..103e656f8aa1e 100644 --- a/packages/react-markup/README.md +++ b/packages/react-markup/README.md @@ -11,13 +11,13 @@ npm install react react-markup ## Usage ```js -import { renderToMarkup } from 'react-markup'; +import { renderToHTML } from 'react-markup'; import EmailTemplate from './my-email-template-component.js' async function action(email, name) { "use server"; // ... in your server, e.g. a Server Action... - const htmlString = await renderToMarkup(); + const htmlString = await renderToHTML(); // ... send e-mail using some e-mail provider await sendEmail({ to: email, contentType: 'text/html', body: htmlString }); } diff --git a/packages/react-markup/src/ReactFizzConfigMarkup.js b/packages/react-markup/src/ReactFizzConfigMarkup.js index 0be7abe8bb0ad..6b43d0bad39a7 100644 --- a/packages/react-markup/src/ReactFizzConfigMarkup.js +++ b/packages/react-markup/src/ReactFizzConfigMarkup.js @@ -95,14 +95,14 @@ export function pushStartInstance( const propValue = props[propKey]; if (propKey === 'ref' && propValue != null) { throw new Error( - 'Cannot pass ref in renderToMarkup because they will never be hydrated.', + 'Cannot pass ref in renderToHTML because they will never be hydrated.', ); } if (typeof propValue === 'function') { throw new Error( 'Cannot pass event handlers (' + propKey + - ') in renderToMarkup because ' + + ') in renderToHTML because ' + 'the HTML will never be hydrated so they can never get called.', ); } diff --git a/packages/react-markup/src/ReactMarkupClient.js b/packages/react-markup/src/ReactMarkupClient.js index 66b69df99bb18..4fb18e27c7d5b 100644 --- a/packages/react-markup/src/ReactMarkupClient.js +++ b/packages/react-markup/src/ReactMarkupClient.js @@ -31,7 +31,7 @@ type MarkupOptions = { onError?: (error: mixed, errorInfo: ErrorInfo) => ?string, }; -export function renderToMarkup( +export function renderToHTML( children: ReactNodeList, options?: MarkupOptions, ): Promise { diff --git a/packages/react-markup/src/ReactMarkupServer.js b/packages/react-markup/src/ReactMarkupServer.js index 7cbab9d430ec6..c6d71e976b256 100644 --- a/packages/react-markup/src/ReactMarkupServer.js +++ b/packages/react-markup/src/ReactMarkupServer.js @@ -71,11 +71,11 @@ type MarkupOptions = { function noServerCallOrFormAction() { throw new Error( - 'renderToMarkup should not have emitted Server References. This is a bug in React.', + 'renderToHTML should not have emitted Server References. This is a bug in React.', ); } -export function renderToMarkup( +export function renderToHTML( children: ReactMarkupNodeList, options?: MarkupOptions, ): Promise { diff --git a/packages/react-markup/src/__tests__/ReactMarkupClient-test.js b/packages/react-markup/src/__tests__/ReactMarkupClient-test.js index 186a1baf7b3b3..a9193474234bb 100644 --- a/packages/react-markup/src/__tests__/ReactMarkupClient-test.js +++ b/packages/react-markup/src/__tests__/ReactMarkupClient-test.js @@ -43,7 +43,7 @@ if (!__EXPERIMENTAL__) { return
hello world
; } - const html = await ReactMarkup.renderToMarkup(); + const html = await ReactMarkup.renderToHTML(); expect(html).toBe('
hello world
'); }); @@ -52,14 +52,14 @@ if (!__EXPERIMENTAL__) { return
{'hello '.repeat(200)}world
; } - const html = await ReactMarkup.renderToMarkup( + const html = await ReactMarkup.renderToHTML( React.createElement(Component), ); expect(html).toBe('
' + ('hello '.repeat(200) + 'world') + '
'); }); it('should prefix html tags with a doctype', async () => { - const html = await ReactMarkup.renderToMarkup( + const html = await ReactMarkup.renderToHTML( hello , @@ -76,7 +76,7 @@ if (!__EXPERIMENTAL__) { } await expect(async () => { - await ReactMarkup.renderToMarkup(); + await ReactMarkup.renderToHTML(); }).rejects.toThrow(); }); @@ -87,7 +87,7 @@ if (!__EXPERIMENTAL__) { } await expect(async () => { - await ReactMarkup.renderToMarkup(); + await ReactMarkup.renderToHTML(); }).rejects.toThrow(); }); @@ -100,7 +100,7 @@ if (!__EXPERIMENTAL__) { } await expect(async () => { - await ReactMarkup.renderToMarkup(); + await ReactMarkup.renderToHTML(); }).rejects.toThrow(); }); @@ -142,7 +142,7 @@ if (!__EXPERIMENTAL__) { ); } - const html = await ReactMarkup.renderToMarkup(); + const html = await ReactMarkup.renderToHTML(); const container = document.createElement('div'); container.innerHTML = html; @@ -176,7 +176,7 @@ if (!__EXPERIMENTAL__) { ); } - const html = await ReactMarkup.renderToMarkup(); + const html = await ReactMarkup.renderToHTML(); expect(html).toBe('
01
'); }); @@ -199,7 +199,7 @@ if (!__EXPERIMENTAL__) { } await expect(async () => { - await ReactMarkup.renderToMarkup( + await ReactMarkup.renderToHTML(
, diff --git a/packages/react-markup/src/__tests__/ReactMarkupServer-test.js b/packages/react-markup/src/__tests__/ReactMarkupServer-test.js index 350f765c1715e..169c4ba5e6c5b 100644 --- a/packages/react-markup/src/__tests__/ReactMarkupServer-test.js +++ b/packages/react-markup/src/__tests__/ReactMarkupServer-test.js @@ -64,7 +64,7 @@ if (!__EXPERIMENTAL__) { return React.createElement('div', null, 'hello world'); } - const html = await ReactMarkup.renderToMarkup( + const html = await ReactMarkup.renderToHTML( React.createElement(Component), ); expect(html).toBe('
hello world
'); @@ -76,14 +76,14 @@ if (!__EXPERIMENTAL__) { return React.createElement('div', null, 'hello '.repeat(200) + 'world'); } - const html = await ReactMarkup.renderToMarkup( + const html = await ReactMarkup.renderToHTML( React.createElement(Component), ); expect(html).toBe('
' + ('hello '.repeat(200) + 'world') + '
'); }); it('should prefix html tags with a doctype', async () => { - const html = await ReactMarkup.renderToMarkup( + const html = await ReactMarkup.renderToHTML( // We can't use JSX because that's client-JSX in our tests. React.createElement( 'html', @@ -104,7 +104,7 @@ if (!__EXPERIMENTAL__) { } await expect(async () => { - await ReactMarkup.renderToMarkup(React.createElement(Component)); + await ReactMarkup.renderToHTML(React.createElement(Component)); }).rejects.toThrow(); }); @@ -116,7 +116,7 @@ if (!__EXPERIMENTAL__) { } await expect(async () => { - await ReactMarkup.renderToMarkup(React.createElement(Component)); + await ReactMarkup.renderToHTML(React.createElement(Component)); }).rejects.toThrow(); }); @@ -130,7 +130,7 @@ if (!__EXPERIMENTAL__) { } await expect(async () => { - await ReactMarkup.renderToMarkup(React.createElement(Component)); + await ReactMarkup.renderToHTML(React.createElement(Component)); }).rejects.toThrow(); }); @@ -173,7 +173,7 @@ if (!__EXPERIMENTAL__) { ); } - const html = await ReactMarkup.renderToMarkup( + const html = await ReactMarkup.renderToHTML( React.createElement(Component), ); const container = document.createElement('div'); @@ -204,7 +204,7 @@ if (!__EXPERIMENTAL__) { return React.createElement('div', null, a, b); } - const html = await ReactMarkup.renderToMarkup( + const html = await ReactMarkup.renderToHTML( React.createElement(Component), ); expect(html).toBe('
00
'); @@ -225,7 +225,7 @@ if (!__EXPERIMENTAL__) { } await expect(async () => { - await ReactMarkup.renderToMarkup( + await ReactMarkup.renderToHTML( React.createElement('div', null, React.createElement(Foo)), { onError(error, errorInfo) { diff --git a/packages/react-server/src/ReactFizzHooks.js b/packages/react-server/src/ReactFizzHooks.js index f5965c4f69096..9d0d9f6c877d8 100644 --- a/packages/react-server/src/ReactFizzHooks.js +++ b/packages/react-server/src/ReactFizzHooks.js @@ -809,7 +809,7 @@ function noop(): void {} function clientHookNotSupported() { throw new Error( - 'Cannot use state or effect Hooks in renderToMarkup because ' + + 'Cannot use state or effect Hooks in renderToHTML because ' + 'this component will never be hydrated.', ); } diff --git a/packages/react-server/src/forks/ReactFlightServerConfig.markup.js b/packages/react-server/src/forks/ReactFlightServerConfig.markup.js index 52a10506bd140..12feb37ac5697 100644 --- a/packages/react-server/src/forks/ReactFlightServerConfig.markup.js +++ b/packages/react-server/src/forks/ReactFlightServerConfig.markup.js @@ -52,9 +52,9 @@ export function getClientReferenceKey( reference: ClientReference, ): ClientReferenceKey { throw new Error( - 'Attempted to render a Client Component from renderToMarkup. ' + + 'Attempted to render a Client Component from renderToHTML. ' + 'This is not supported since it will never hydrate. ' + - 'Only render Server Components with renderToMarkup.', + 'Only render Server Components with renderToHTML.', ); } @@ -63,9 +63,9 @@ export function resolveClientReferenceMetadata( clientReference: ClientReference, ): ClientReferenceMetadata { throw new Error( - 'Attempted to render a Client Component from renderToMarkup. ' + + 'Attempted to render a Client Component from renderToHTML. ' + 'This is not supported since it will never hydrate. ' + - 'Only render Server Components with renderToMarkup.', + 'Only render Server Components with renderToHTML.', ); } @@ -74,7 +74,7 @@ export function getServerReferenceId( serverReference: ServerReference, ): ServerReferenceId { throw new Error( - 'Attempted to render a Server Action from renderToMarkup. ' + + 'Attempted to render a Server Action from renderToHTML. ' + 'This is not supported since it varies by version of the app. ' + 'Use a fixed URL for any forms instead.', ); @@ -85,7 +85,7 @@ export function getServerReferenceBoundArguments( serverReference: ServerReference, ): null | Array { throw new Error( - 'Attempted to render a Server Action from renderToMarkup. ' + + 'Attempted to render a Server Action from renderToHTML. ' + 'This is not supported since it varies by version of the app. ' + 'Use a fixed URL for any forms instead.', ); diff --git a/scripts/error-codes/codes.json b/scripts/error-codes/codes.json index b1286a7daf7c0..572ffd21fd8b5 100644 --- a/scripts/error-codes/codes.json +++ b/scripts/error-codes/codes.json @@ -517,13 +517,13 @@ "529": "Expected stylesheet with precedence to not be updated to a different kind of . Check the `rel`, `href`, and `precedence` props of this component. Alternatively, check whether two different components render in the same slot or share the same key.%s", "530": "The render was aborted by the server with a promise.", "531": "react-markup is not supported outside a React Server Components environment.", - "532": "Attempted to render a Client Component from renderToMarkup. This is not supported since it will never hydrate. Only render Server Components with renderToMarkup.", - "533": "Attempted to render a Server Action from renderToMarkup. This is not supported since it varies by version of the app. Use a fixed URL for any forms instead.", - "534": "renderToMarkup should not have emitted Client References. This is a bug in React.", - "535": "renderToMarkup should not have emitted Server References. This is a bug in React.", - "536": "Cannot pass ref in renderToMarkup because they will never be hydrated.", - "537": "Cannot pass event handlers (%s) in renderToMarkup because the HTML will never be hydrated so they can never get called.", - "538": "Cannot use state or effect Hooks in renderToMarkup because this component will never be hydrated.", + "532": "Attempted to render a Client Component from renderToHTML. This is not supported since it will never hydrate. Only render Server Components with renderToHTML.", + "533": "Attempted to render a Server Action from renderToHTML. This is not supported since it varies by version of the app. Use a fixed URL for any forms instead.", + "534": "renderToHTML should not have emitted Client References. This is a bug in React.", + "535": "renderToHTML should not have emitted Server References. This is a bug in React.", + "536": "Cannot pass ref in renderToHTML because they will never be hydrated.", + "537": "Cannot pass event handlers (%s) in renderToHTML because the HTML will never be hydrated so they can never get called.", + "538": "Cannot use state or effect Hooks in renderToHTML because this component will never be hydrated.", "539": "Binary RSC chunks cannot be encoded as strings. This is a bug in the wiring of the React streams.", "540": "String chunks need to be passed in their original shape. Not split into smaller string chunks. This is a bug in the wiring of the React streams.", "541": "Compared context values must be arrays"