Reputation: 519
I render react component on server and when go to route get error message:
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())
Upvotes: 4
Views: 9257
Reputation: 546
I suggest you write it like this:
const ReactDOMServer = require('react-dom/server');
const appHtml = ReactDOMServer.renderToStaticMarkup (
<Provider store={store}>
<StaticRouter location={location} context={routeContext}>
<App />
</StaticRouter>
</Provider>
);
I hope it helps you.
Upvotes: 8