mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[Flight] Move Flight DOM to a Webpack Specific Package (#17372)
* Move Flight DOM to Webpack Specific Packagee We'll have Webpack specific coupling so we need to ensure that it can be versioned separately from various Webpack versions. We'll also have builds for other bundlers in the future. * Move to peerDep * Move DOM Flight Tests * Merge ReactFlightIntegration into ReactFlightDOM This was an integration test. We can add to it. * Fix fixture paths
This commit is contained in:
committed by
GitHub
parent
532810a370
commit
39dbb14da3
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import {convertStringToBuffer} from 'react-server/src/ReactServerHostConfig';
|
||||
|
||||
import ReactDOMServer from 'react-dom/server';
|
||||
|
||||
export function formatChunkAsString(type: string, props: Object): string {
|
||||
let str = '<' + type + '>';
|
||||
if (typeof props.children === 'string') {
|
||||
str += props.children;
|
||||
}
|
||||
str += '</' + type + '>';
|
||||
return str;
|
||||
}
|
||||
|
||||
export function formatChunk(type: string, props: Object): Uint8Array {
|
||||
return convertStringToBuffer(formatChunkAsString(type, props));
|
||||
}
|
||||
|
||||
export function renderHostChildrenToString(
|
||||
children: React$Element<any>,
|
||||
): string {
|
||||
// TODO: This file is used to actually implement a server renderer
|
||||
// so we can't actually reference the renderer here. Instead, we
|
||||
// should replace this method with a reference to Fizz which
|
||||
// then uses this file to implement the server renderer.
|
||||
return ReactDOMServer.renderToStaticMarkup(children);
|
||||
}
|
||||
Reference in New Issue
Block a user