Skip to content

Commit 5c9243d

Browse files
authored
Rename renderToMarkup to renderToHTML (facebook#30689)
1 parent e0a0e65 commit 5c9243d

File tree

10 files changed

+43
-43
lines changed

10 files changed

+43
-43
lines changed

packages/react-client/src/forks/ReactFlightClientConfig.markup.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function prepareDestinationForModule(
2525
metadata: ClientReferenceMetadata,
2626
) {
2727
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.',
2929
);
3030
}
3131

@@ -34,7 +34,7 @@ export function resolveClientReference<T>(
3434
metadata: ClientReferenceMetadata,
3535
): ClientReference<T> {
3636
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.',
3838
);
3939
}
4040

@@ -43,7 +43,7 @@ export function resolveServerReference<T>(
4343
id: ServerReferenceId,
4444
): ClientReference<T> {
4545
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.',
4747
);
4848
}
4949

@@ -55,7 +55,7 @@ export function preloadModule<T>(
5555

5656
export function requireModule<T>(metadata: ClientReference<T>): T {
5757
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.',
5959
);
6060
}
6161

packages/react-markup/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ npm install react react-markup
1111
## Usage
1212

1313
```js
14-
import { renderToMarkup } from 'react-markup';
14+
import { renderToHTML } from 'react-markup';
1515
import EmailTemplate from './my-email-template-component.js'
1616

1717
async function action(email, name) {
1818
"use server";
1919
// ... in your server, e.g. a Server Action...
20-
const htmlString = await renderToMarkup(<EmailTemplate name={name} />);
20+
const htmlString = await renderToHTML(<EmailTemplate name={name} />);
2121
// ... send e-mail using some e-mail provider
2222
await sendEmail({ to: email, contentType: 'text/html', body: htmlString });
2323
}

packages/react-markup/src/ReactFizzConfigMarkup.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ export function pushStartInstance(
9595
const propValue = props[propKey];
9696
if (propKey === 'ref' && propValue != null) {
9797
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.',
9999
);
100100
}
101101
if (typeof propValue === 'function') {
102102
throw new Error(
103103
'Cannot pass event handlers (' +
104104
propKey +
105-
') in renderToMarkup because ' +
105+
') in renderToHTML because ' +
106106
'the HTML will never be hydrated so they can never get called.',
107107
);
108108
}

packages/react-markup/src/ReactMarkupClient.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type MarkupOptions = {
3131
onError?: (error: mixed, errorInfo: ErrorInfo) => ?string,
3232
};
3333

34-
export function renderToMarkup(
34+
export function renderToHTML(
3535
children: ReactNodeList,
3636
options?: MarkupOptions,
3737
): Promise<string> {

packages/react-markup/src/ReactMarkupServer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ type MarkupOptions = {
7171

7272
function noServerCallOrFormAction() {
7373
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.',
7575
);
7676
}
7777

78-
export function renderToMarkup(
78+
export function renderToHTML(
7979
children: ReactMarkupNodeList,
8080
options?: MarkupOptions,
8181
): Promise<string> {

packages/react-markup/src/__tests__/ReactMarkupClient-test.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ if (!__EXPERIMENTAL__) {
4343
return <div>hello world</div>;
4444
}
4545

46-
const html = await ReactMarkup.renderToMarkup(<Component />);
46+
const html = await ReactMarkup.renderToHTML(<Component />);
4747
expect(html).toBe('<div>hello world</div>');
4848
});
4949

@@ -52,14 +52,14 @@ if (!__EXPERIMENTAL__) {
5252
return <div>{'hello '.repeat(200)}world</div>;
5353
}
5454

55-
const html = await ReactMarkup.renderToMarkup(
55+
const html = await ReactMarkup.renderToHTML(
5656
React.createElement(Component),
5757
);
5858
expect(html).toBe('<div>' + ('hello '.repeat(200) + 'world') + '</div>');
5959
});
6060

6161
it('should prefix html tags with a doctype', async () => {
62-
const html = await ReactMarkup.renderToMarkup(
62+
const html = await ReactMarkup.renderToHTML(
6363
<html>
6464
<body>hello</body>
6565
</html>,
@@ -76,7 +76,7 @@ if (!__EXPERIMENTAL__) {
7676
}
7777

7878
await expect(async () => {
79-
await ReactMarkup.renderToMarkup(<Component />);
79+
await ReactMarkup.renderToHTML(<Component />);
8080
}).rejects.toThrow();
8181
});
8282

@@ -87,7 +87,7 @@ if (!__EXPERIMENTAL__) {
8787
}
8888

8989
await expect(async () => {
90-
await ReactMarkup.renderToMarkup(<Component />);
90+
await ReactMarkup.renderToHTML(<Component />);
9191
}).rejects.toThrow();
9292
});
9393

@@ -100,7 +100,7 @@ if (!__EXPERIMENTAL__) {
100100
}
101101

102102
await expect(async () => {
103-
await ReactMarkup.renderToMarkup(<Component />);
103+
await ReactMarkup.renderToHTML(<Component />);
104104
}).rejects.toThrow();
105105
});
106106

@@ -142,7 +142,7 @@ if (!__EXPERIMENTAL__) {
142142
);
143143
}
144144

145-
const html = await ReactMarkup.renderToMarkup(<Component />);
145+
const html = await ReactMarkup.renderToHTML(<Component />);
146146
const container = document.createElement('div');
147147
container.innerHTML = html;
148148

@@ -176,7 +176,7 @@ if (!__EXPERIMENTAL__) {
176176
);
177177
}
178178

179-
const html = await ReactMarkup.renderToMarkup(<Component />);
179+
const html = await ReactMarkup.renderToHTML(<Component />);
180180
expect(html).toBe('<div>01</div>');
181181
});
182182

@@ -199,7 +199,7 @@ if (!__EXPERIMENTAL__) {
199199
}
200200

201201
await expect(async () => {
202-
await ReactMarkup.renderToMarkup(
202+
await ReactMarkup.renderToHTML(
203203
<div>
204204
<Foo />
205205
</div>,

packages/react-markup/src/__tests__/ReactMarkupServer-test.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ if (!__EXPERIMENTAL__) {
6464
return React.createElement('div', null, 'hello world');
6565
}
6666

67-
const html = await ReactMarkup.renderToMarkup(
67+
const html = await ReactMarkup.renderToHTML(
6868
React.createElement(Component),
6969
);
7070
expect(html).toBe('<div>hello world</div>');
@@ -76,14 +76,14 @@ if (!__EXPERIMENTAL__) {
7676
return React.createElement('div', null, 'hello '.repeat(200) + 'world');
7777
}
7878

79-
const html = await ReactMarkup.renderToMarkup(
79+
const html = await ReactMarkup.renderToHTML(
8080
React.createElement(Component),
8181
);
8282
expect(html).toBe('<div>' + ('hello '.repeat(200) + 'world') + '</div>');
8383
});
8484

8585
it('should prefix html tags with a doctype', async () => {
86-
const html = await ReactMarkup.renderToMarkup(
86+
const html = await ReactMarkup.renderToHTML(
8787
// We can't use JSX because that's client-JSX in our tests.
8888
React.createElement(
8989
'html',
@@ -104,7 +104,7 @@ if (!__EXPERIMENTAL__) {
104104
}
105105

106106
await expect(async () => {
107-
await ReactMarkup.renderToMarkup(React.createElement(Component));
107+
await ReactMarkup.renderToHTML(React.createElement(Component));
108108
}).rejects.toThrow();
109109
});
110110

@@ -116,7 +116,7 @@ if (!__EXPERIMENTAL__) {
116116
}
117117

118118
await expect(async () => {
119-
await ReactMarkup.renderToMarkup(React.createElement(Component));
119+
await ReactMarkup.renderToHTML(React.createElement(Component));
120120
}).rejects.toThrow();
121121
});
122122

@@ -130,7 +130,7 @@ if (!__EXPERIMENTAL__) {
130130
}
131131

132132
await expect(async () => {
133-
await ReactMarkup.renderToMarkup(React.createElement(Component));
133+
await ReactMarkup.renderToHTML(React.createElement(Component));
134134
}).rejects.toThrow();
135135
});
136136

@@ -173,7 +173,7 @@ if (!__EXPERIMENTAL__) {
173173
);
174174
}
175175

176-
const html = await ReactMarkup.renderToMarkup(
176+
const html = await ReactMarkup.renderToHTML(
177177
React.createElement(Component),
178178
);
179179
const container = document.createElement('div');
@@ -204,7 +204,7 @@ if (!__EXPERIMENTAL__) {
204204
return React.createElement('div', null, a, b);
205205
}
206206

207-
const html = await ReactMarkup.renderToMarkup(
207+
const html = await ReactMarkup.renderToHTML(
208208
React.createElement(Component),
209209
);
210210
expect(html).toBe('<div>00</div>');
@@ -225,7 +225,7 @@ if (!__EXPERIMENTAL__) {
225225
}
226226

227227
await expect(async () => {
228-
await ReactMarkup.renderToMarkup(
228+
await ReactMarkup.renderToHTML(
229229
React.createElement('div', null, React.createElement(Foo)),
230230
{
231231
onError(error, errorInfo) {

packages/react-server/src/ReactFizzHooks.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ function noop(): void {}
804804

805805
function clientHookNotSupported() {
806806
throw new Error(
807-
'Cannot use state or effect Hooks in renderToMarkup because ' +
807+
'Cannot use state or effect Hooks in renderToHTML because ' +
808808
'this component will never be hydrated.',
809809
);
810810
}

packages/react-server/src/forks/ReactFlightServerConfig.markup.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ export function getClientReferenceKey(
5252
reference: ClientReference<any>,
5353
): ClientReferenceKey {
5454
throw new Error(
55-
'Attempted to render a Client Component from renderToMarkup. ' +
55+
'Attempted to render a Client Component from renderToHTML. ' +
5656
'This is not supported since it will never hydrate. ' +
57-
'Only render Server Components with renderToMarkup.',
57+
'Only render Server Components with renderToHTML.',
5858
);
5959
}
6060

@@ -63,9 +63,9 @@ export function resolveClientReferenceMetadata<T>(
6363
clientReference: ClientReference<T>,
6464
): ClientReferenceMetadata {
6565
throw new Error(
66-
'Attempted to render a Client Component from renderToMarkup. ' +
66+
'Attempted to render a Client Component from renderToHTML. ' +
6767
'This is not supported since it will never hydrate. ' +
68-
'Only render Server Components with renderToMarkup.',
68+
'Only render Server Components with renderToHTML.',
6969
);
7070
}
7171

@@ -74,7 +74,7 @@ export function getServerReferenceId<T>(
7474
serverReference: ServerReference<T>,
7575
): ServerReferenceId {
7676
throw new Error(
77-
'Attempted to render a Server Action from renderToMarkup. ' +
77+
'Attempted to render a Server Action from renderToHTML. ' +
7878
'This is not supported since it varies by version of the app. ' +
7979
'Use a fixed URL for any forms instead.',
8080
);
@@ -85,7 +85,7 @@ export function getServerReferenceBoundArguments<T>(
8585
serverReference: ServerReference<T>,
8686
): null | Array<ReactClientValue> {
8787
throw new Error(
88-
'Attempted to render a Server Action from renderToMarkup. ' +
88+
'Attempted to render a Server Action from renderToHTML. ' +
8989
'This is not supported since it varies by version of the app. ' +
9090
'Use a fixed URL for any forms instead.',
9191
);

scripts/error-codes/codes.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -517,13 +517,13 @@
517517
"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",
518518
"530": "The render was aborted by the server with a promise.",
519519
"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.",
527527
"539": "Binary RSC chunks cannot be encoded as strings. This is a bug in the wiring of the React streams.",
528528
"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.",
529529
"541": "Compared context values must be arrays"

0 commit comments

Comments
 (0)