Skip to content

Commit

Permalink
fix: csr add reactToString
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyuang committed Mar 10, 2020
1 parent 79aa0e6 commit 579c08b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/ykfe-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ykfe-utils",
"version": "3.5.3",
"version": "3.5.4",
"description": "utils for ykfe",
"main": "lib/index.js",
"module": "es/index.js",
Expand Down
8 changes: 6 additions & 2 deletions packages/ykfe-utils/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { resolve } from 'path'
import { Readable, PassThrough } from 'stream'
import React from 'react'
import { renderToNodeStream } from 'react-dom/server'
import { renderToNodeStream, renderToString as reactRenderToString } from 'react-dom/server'
import { Config } from '../interface/config'

const { renderToString } = require('rax-server-renderer')
Expand All @@ -12,7 +12,11 @@ const logGreen = (text: string) => {
}

const reactToStream = (Component: React.FunctionComponent, props: object, config: Config) => {
return config.isRax ? renderToString(React.createElement(Component, props)) : renderToNodeStream(React.createElement(Component, props))
if (config.useReactToString) {
return reactRenderToString(React.createElement(Component, props))
} else {
return config.isRax ? renderToString(React.createElement(Component, props)) : renderToNodeStream(React.createElement(Component, props))
}
}

const getVersion = (str: string) => {
Expand Down

0 comments on commit 579c08b

Please sign in to comment.