ReactDOMServer.renderToString不是一个函数
我渲染响应组件在服务器上,当去路由获取错误消息:
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())
我build议你这样写:
const ReactDOMServer = require('react-dom/server'); const appHtml = ReactDOMServer.renderToStaticMarkup ( <Provider store={store}> <StaticRouter location={location} context={routeContext}> <App /> </StaticRouter> </Provider> );
我希望它可以帮助你。