简体   繁体   English

TypeError:无法设置undefined的属性'props'

[英]TypeError: Cannot set property 'props' of undefined

I'm trying to set up server side rendering with react. 我正在尝试使用react设置服务器端渲染。 Whenever I access the route in which I want server side rendering working, I get the error TypeError: Cannot set property 'props' of undefined . 每当我访问我希望服务器端渲染工作的路由时,我都会收到错误TypeError: Cannot set property 'props' of undefined

My router looks like this: 我的路由器看起来像这样:

import DetailsPage from './DetailsPage.jsx';
import Home from './Home.jsx';

const routes = (
    <Route name="app" path="/" handler={App}>
        <Route name="platform" path="platform" handler={Home}/>
        <Route name="details" path="platform/details/:carId" handler={DetailsPage}/>
    </Route>
);

The rendering code looks like this: 渲染代码如下所示:

Router.run(routes, this.request.url, function (Handler) {
      var content = React.renderToString(<Handler/>);
      reactBody = render('platform/index', {htmlReactApp: content});
    });

This happens using react 0.13.3 . 使用反应0.13.3会发生这种情况。

Something tells me it is an issue with react and not react-router. 有些东西告诉我这是一个反应而不是反应路由器的问题。

Has anybody been through this before? 以前有人经历过这个吗?

So guys, this issue has been resolved. 所以伙计们,这个问题已经解决了。 The problem was that the directory in which the project lives was being cached by the OS, thus the code wasn't correctly updated when I thought it was. 问题是操作系统正在缓存项目所在的目录,因此我认为代码没有正确更新。

I solved it by deleting the directory and cloning the git repository back into the system, after a npm install, things worked smoothly again. 我通过删除目录并将git存储库克隆回系统来解决它,在安装npm之后,事情再次顺利进行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM