Created
December 29, 2021 02:16
-
-
Save 0916dhkim/3896308c7c677a59e4affe9b8037a378 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Original demo. | |
async function renderReactTree(res, props) { | |
await waitForWebpack(); | |
const manifest = readFileSync( | |
path.resolve(__dirname, '../build/react-client-manifest.json'), | |
'utf8' | |
); | |
const moduleMap = JSON.parse(manifest); | |
pipeToNodeWritable(React.createElement(ReactApp, props), res, moduleMap); | |
} | |
// Generalized version. | |
async function renderReactTree(res, component, props) { | |
await waitForWebpack(); | |
const manifest = readFileSync( | |
path.resolve(__dirname, '../build/react-client-manifest.json'), | |
'utf8' | |
); | |
const moduleMap = JSON.parse(manifest); | |
pipeToNodeWritable(React.createElement(component, props), res, moduleMap); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment