简体   繁体   中英

TypeError: Cannot set property 'props' of undefined

I'm trying to set up server side rendering with 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 .

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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