const renderToString = ReactDOMServer.renderToString
const fac = React.createFactory(React.createClass({
render: function() {
return (
<Provider store={store}>
<StaticRouter location={location} context={routeContext}>
<App />
</StaticRouter>
</Provider>
)
}}))
const appHtml = renderToString(fac())
最佳答案
我建议你这样写:
const ReactDOMServer = require('react-dom/server');
const appHtml = ReactDOMServer.renderToStaticMarkup (
<Provider store={store}>
<StaticRouter location={location} context={routeContext}>
<App />
</StaticRouter>
</Provider>
);
希望对您有帮助。
关于javascript - ReactDOMServer.renderToString不是一个函数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42953629/