@samitouri / QOS-React / commits / 5c9243d153

Rename `renderToMarkup` to `renderToHTML` (#30689)

Sebastian Silbermann committed Aug 14, 2024 at 19:35 UTC 5c9243d1537ee7bc32f6f2a1e4bd35bbb491a0f5
10 files changed +43 -43
packages/react-client/src/forks/ReactFlightClientConfig.markup.js
+4 -4
@@ -25,7 +25,7 @@ export function prepareDestinationForModule(
25 metadata: ClientReferenceMetadata,
26 ) {
27 throw new Error(
28 - 'renderToMarkup should not have emitted Client References. This is a bug in React.',
28 + 'renderToHTML should not have emitted Client References. This is a bug in React.',
29 );
30 }
31
@@ -34,7 +34,7 @@ export function resolveClientReference<T>(
34 metadata: ClientReferenceMetadata,
35 ): ClientReference<T> {
36 throw new Error(
37 - 'renderToMarkup should not have emitted Client References. This is a bug in React.',
37 + 'renderToHTML should not have emitted Client References. This is a bug in React.',
38 );
39 }
40
@@ -43,7 +43,7 @@ export function resolveServerReference<T>(
43 id: ServerReferenceId,
44 ): ClientReference<T> {
45 throw new Error(
46 - 'renderToMarkup should not have emitted Server References. This is a bug in React.',
46 + 'renderToHTML should not have emitted Server References. This is a bug in React.',
47 );
48 }
49
@@ -55,7 +55,7 @@ export function preloadModule<T>(
55
56 export function requireModule<T>(metadata: ClientReference<T>): T {
57 throw new Error(
58 - 'renderToMarkup should not have emitted Client References. This is a bug in React.',
58 + 'renderToHTML should not have emitted Client References. This is a bug in React.',
59 );
60 }
61
packages/react-markup/README.md
+2 -2
@@ -11,13 +11,13 @@ npm install react react-markup
11 ## Usage
12
13 ```js
14 -import { renderToMarkup } from 'react-markup';
14 +import { renderToHTML } from 'react-markup';
15 import EmailTemplate from './my-email-template-component.js'
16
17 async function action(email, name) {
18 "use server";
19 // ... in your server, e.g. a Server Action...
20 - const htmlString = await renderToMarkup(<EmailTemplate name={name} />);
20 + const htmlString = await renderToHTML(<EmailTemplate name={name} />);
21 // ... send e-mail using some e-mail provider
22 await sendEmail({ to: email, contentType: 'text/html', body: htmlString });
23 }
packages/react-markup/src/ReactFizzConfigMarkup.js
+2 -2
@@ -95,14 +95,14 @@ export function pushStartInstance(
95 const propValue = props[propKey];
96 if (propKey === 'ref' && propValue != null) {
97 throw new Error(
98 - 'Cannot pass ref in renderToMarkup because they will never be hydrated.',
98 + 'Cannot pass ref in renderToHTML because they will never be hydrated.',
99 );
100 }
101 if (typeof propValue === 'function') {
102 throw new Error(
103 'Cannot pass event handlers (' +
104 propKey +
105 - ') in renderToMarkup because ' +
105 + ') in renderToHTML because ' +
106 'the HTML will never be hydrated so they can never get called.',
107 );
108 }
packages/react-markup/src/ReactMarkupClient.js
+1 -1
@@ -31,7 +31,7 @@ type MarkupOptions = {
31 onError?: (error: mixed, errorInfo: ErrorInfo) => ?string,
32 };
33
34 -export function renderToMarkup(
34 +export function renderToHTML(
35 children: ReactNodeList,
36 options?: MarkupOptions,
37 ): Promise<string> {
packages/react-markup/src/ReactMarkupServer.js
+2 -2
@@ -71,11 +71,11 @@ type MarkupOptions = {
71
72 function noServerCallOrFormAction() {
73 throw new Error(
74 - 'renderToMarkup should not have emitted Server References. This is a bug in React.',
74 + 'renderToHTML should not have emitted Server References. This is a bug in React.',
75 );
76 }
77
78 -export function renderToMarkup(
78 +export function renderToHTML(
79 children: ReactMarkupNodeList,
80 options?: MarkupOptions,
81 ): Promise<string> {
packages/react-markup/src/__tests__/ReactMarkupClient-test.js
+9 -9
@@ -43,7 +43,7 @@ if (!__EXPERIMENTAL__) {
43 return <div>hello world</div>;
44 }
45
46 - const html = await ReactMarkup.renderToMarkup(<Component />);
46 + const html = await ReactMarkup.renderToHTML(<Component />);
47 expect(html).toBe('<div>hello world</div>');
48 });
49
@@ -52,14 +52,14 @@ if (!__EXPERIMENTAL__) {
52 return <div>{'hello '.repeat(200)}world</div>;
53 }
54
55 - const html = await ReactMarkup.renderToMarkup(
55 + const html = await ReactMarkup.renderToHTML(
56 React.createElement(Component),
57 );
58 expect(html).toBe('<div>' + ('hello '.repeat(200) + 'world') + '</div>');
59 });
60
61 it('should prefix html tags with a doctype', async () => {
62 - const html = await ReactMarkup.renderToMarkup(
62 + const html = await ReactMarkup.renderToHTML(
63 <html>
64 <body>hello</body>
65 </html>,
@@ -76,7 +76,7 @@ if (!__EXPERIMENTAL__) {
76 }
77
78 await expect(async () => {
79 - await ReactMarkup.renderToMarkup(<Component />);
79 + await ReactMarkup.renderToHTML(<Component />);
80 }).rejects.toThrow();
81 });
82
@@ -87,7 +87,7 @@ if (!__EXPERIMENTAL__) {
87 }
88
89 await expect(async () => {
90 - await ReactMarkup.renderToMarkup(<Component />);
90 + await ReactMarkup.renderToHTML(<Component />);
91 }).rejects.toThrow();
92 });
93
@@ -100,7 +100,7 @@ if (!__EXPERIMENTAL__) {
100 }
101
102 await expect(async () => {
103 - await ReactMarkup.renderToMarkup(<Component />);
103 + await ReactMarkup.renderToHTML(<Component />);
104 }).rejects.toThrow();
105 });
106
@@ -142,7 +142,7 @@ if (!__EXPERIMENTAL__) {
142 );
143 }
144
145 - const html = await ReactMarkup.renderToMarkup(<Component />);
145 + const html = await ReactMarkup.renderToHTML(<Component />);
146 const container = document.createElement('div');
147 container.innerHTML = html;
148
@@ -176,7 +176,7 @@ if (!__EXPERIMENTAL__) {
176 );
177 }
178
179 - const html = await ReactMarkup.renderToMarkup(<Component />);
179 + const html = await ReactMarkup.renderToHTML(<Component />);
180 expect(html).toBe('<div>01</div>');
181 });
182
@@ -199,7 +199,7 @@ if (!__EXPERIMENTAL__) {
199 }
200
201 await expect(async () => {
202 - await ReactMarkup.renderToMarkup(
202 + await ReactMarkup.renderToHTML(
203 <div>
204 <Foo />
205 </div>,
packages/react-markup/src/__tests__/ReactMarkupServer-test.js
+9 -9
@@ -64,7 +64,7 @@ if (!__EXPERIMENTAL__) {
64 return React.createElement('div', null, 'hello world');
65 }
66
67 - const html = await ReactMarkup.renderToMarkup(
67 + const html = await ReactMarkup.renderToHTML(
68 React.createElement(Component),
69 );
70 expect(html).toBe('<div>hello world</div>');
@@ -76,14 +76,14 @@ if (!__EXPERIMENTAL__) {
76 return React.createElement('div', null, 'hello '.repeat(200) + 'world');
77 }
78
79 - const html = await ReactMarkup.renderToMarkup(
79 + const html = await ReactMarkup.renderToHTML(
80 React.createElement(Component),
81 );
82 expect(html).toBe('<div>' + ('hello '.repeat(200) + 'world') + '</div>');
83 });
84
85 it('should prefix html tags with a doctype', async () => {
86 - const html = await ReactMarkup.renderToMarkup(
86 + const html = await ReactMarkup.renderToHTML(
87 // We can't use JSX because that's client-JSX in our tests.
88 React.createElement(
89 'html',
@@ -104,7 +104,7 @@ if (!__EXPERIMENTAL__) {
104 }
105
106 await expect(async () => {
107 - await ReactMarkup.renderToMarkup(React.createElement(Component));
107 + await ReactMarkup.renderToHTML(React.createElement(Component));
108 }).rejects.toThrow();
109 });
110
@@ -116,7 +116,7 @@ if (!__EXPERIMENTAL__) {
116 }
117
118 await expect(async () => {
119 - await ReactMarkup.renderToMarkup(React.createElement(Component));
119 + await ReactMarkup.renderToHTML(React.createElement(Component));
120 }).rejects.toThrow();
121 });
122
@@ -130,7 +130,7 @@ if (!__EXPERIMENTAL__) {
130 }
131
132 await expect(async () => {
133 - await ReactMarkup.renderToMarkup(React.createElement(Component));
133 + await ReactMarkup.renderToHTML(React.createElement(Component));
134 }).rejects.toThrow();
135 });
136
@@ -173,7 +173,7 @@ if (!__EXPERIMENTAL__) {
173 );
174 }
175
176 - const html = await ReactMarkup.renderToMarkup(
176 + const html = await ReactMarkup.renderToHTML(
177 React.createElement(Component),
178 );
179 const container = document.createElement('div');
@@ -204,7 +204,7 @@ if (!__EXPERIMENTAL__) {
204 return React.createElement('div', null, a, b);
205 }
206
207 - const html = await ReactMarkup.renderToMarkup(
207 + const html = await ReactMarkup.renderToHTML(
208 React.createElement(Component),
209 );
210 expect(html).toBe('<div>00</div>');
@@ -225,7 +225,7 @@ if (!__EXPERIMENTAL__) {
225 }
226
227 await expect(async () => {
228 - await ReactMarkup.renderToMarkup(
228 + await ReactMarkup.renderToHTML(
229 React.createElement('div', null, React.createElement(Foo)),
230 {
231 onError(error, errorInfo) {
packages/react-server/src/ReactFizzHooks.js
+1 -1
@@ -804,7 +804,7 @@ function noop(): void {}
804
805 function clientHookNotSupported() {
806 throw new Error(
807 - 'Cannot use state or effect Hooks in renderToMarkup because ' +
807 + 'Cannot use state or effect Hooks in renderToHTML because ' +
808 'this component will never be hydrated.',
809 );
810 }
packages/react-server/src/forks/ReactFlightServerConfig.markup.js
+6 -6
@@ -52,9 +52,9 @@ export function getClientReferenceKey(
52 reference: ClientReference<any>,
53 ): ClientReferenceKey {
54 throw new Error(
55 - 'Attempted to render a Client Component from renderToMarkup. ' +
55 + 'Attempted to render a Client Component from renderToHTML. ' +
56 'This is not supported since it will never hydrate. ' +
57 - 'Only render Server Components with renderToMarkup.',
57 + 'Only render Server Components with renderToHTML.',
58 );
59 }
60
@@ -63,9 +63,9 @@ export function resolveClientReferenceMetadata<T>(
63 clientReference: ClientReference<T>,
64 ): ClientReferenceMetadata {
65 throw new Error(
66 - 'Attempted to render a Client Component from renderToMarkup. ' +
66 + 'Attempted to render a Client Component from renderToHTML. ' +
67 'This is not supported since it will never hydrate. ' +
68 - 'Only render Server Components with renderToMarkup.',
68 + 'Only render Server Components with renderToHTML.',
69 );
70 }
71
@@ -74,7 +74,7 @@ export function getServerReferenceId<T>(
74 serverReference: ServerReference<T>,
75 ): ServerReferenceId {
76 throw new Error(
77 - 'Attempted to render a Server Action from renderToMarkup. ' +
77 + 'Attempted to render a Server Action from renderToHTML. ' +
78 'This is not supported since it varies by version of the app. ' +
79 'Use a fixed URL for any forms instead.',
80 );
@@ -85,7 +85,7 @@ export function getServerReferenceBoundArguments<T>(
85 serverReference: ServerReference<T>,
86 ): null | Array<ReactClientValue> {
87 throw new Error(
88 - 'Attempted to render a Server Action from renderToMarkup. ' +
88 + 'Attempted to render a Server Action from renderToHTML. ' +
89 'This is not supported since it varies by version of the app. ' +
90 'Use a fixed URL for any forms instead.',
91 );
scripts/error-codes/codes.json
+7 -7
@@ -517,13 +517,13 @@
517 "529": "Expected stylesheet with precedence to not be updated to a different kind of <link>. Check the `rel`, `href`, and `precedence` props of this component. Alternatively, check whether two different <link> components render in the same slot or share the same key.%s",
518 "530": "The render was aborted by the server with a promise.",
519 "531": "react-markup is not supported outside a React Server Components environment.",
520 - "532": "Attempted to render a Client Component from renderToMarkup. This is not supported since it will never hydrate. Only render Server Components with renderToMarkup.",
521 - "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.",
522 - "534": "renderToMarkup should not have emitted Client References. This is a bug in React.",
523 - "535": "renderToMarkup should not have emitted Server References. This is a bug in React.",
524 - "536": "Cannot pass ref in renderToMarkup because they will never be hydrated.",
525 - "537": "Cannot pass event handlers (%s) in renderToMarkup because the HTML will never be hydrated so they can never get called.",
526 - "538": "Cannot use state or effect Hooks in renderToMarkup because this component will never be hydrated.",
520 + "532": "Attempted to render a Client Component from renderToHTML. This is not supported since it will never hydrate. Only render Server Components with renderToHTML.",
521 + "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.",
522 + "534": "renderToHTML should not have emitted Client References. This is a bug in React.",
523 + "535": "renderToHTML should not have emitted Server References. This is a bug in React.",
524 + "536": "Cannot pass ref in renderToHTML because they will never be hydrated.",
525 + "537": "Cannot pass event handlers (%s) in renderToHTML because the HTML will never be hydrated so they can never get called.",
526 + "538": "Cannot use state or effect Hooks in renderToHTML because this component will never be hydrated.",
527 "539": "Binary RSC chunks cannot be encoded as strings. This is a bug in the wiring of the React streams.",
528 "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.",
529 "541": "Compared context values must be arrays"