我正在尝试重现this教程(它已经过时了)并且在这个地方
var html = ReactDOM.renderToString(React.createElement(Router.RouterContext, renderProps));
我收到此错误:
Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components).
由
触发的错误import createBrowserHistory from 'history/createBrowserHistory';
let history = createBrowserHistory();
ReactDOM.render(
<Router history={history}>
{routes}
</Router>,
document.getElementById('app')
);
我是React的新手所以也许你可以帮助我?
答案 0 :(得分:0)
在这些部分之后有一个更新:
October 19, 2015 Update: Previous React.renderToString now lives
in the react-dom/server package. Additionally, server-side rendering
with React Router has changed quite a bit. See Server Rendering
Guide for more details.
您似乎需要根据“服务器渲染指南”进行设置。