javascript - Uncaught TypeError rendering <Router> using React Router in ES6: type.toUpperCase is not a function -


i upgraded react v. 0.14.0, reactdom v. 0.14.0 , react router v. 1.0.0-rc3 , i'm struggling following error. i've read , tried solutions in this , this post, cannot work code, uses es6.

the error occurs in client-side app.js when calling reactdom.render method.

import react 'react'; import reactdom 'react-dom'; import router 'react-router'; import routes './routes'; import createbrowserhistory 'history/lib/createbrowserhistory';  let app = document.getelementbyid('app'); let history = createbrowserhistory(); reactdom.render(<router routes={routes} history={history} />, app); 

and routes.js.

import react 'react'; import {route, indexroute} 'react-router'; import app './components/app'; import home './components/home';  export default (     <route path="/" component={app}>         <indexroute component={home} />     </route> ); 

and completeness, server-side rendering middleware, seems working fine.

app.use(function(req, res) {     match(         { routes, location: req.path },         (error, redirectlocation, renderprops) => {             if (error) {                 res.send(500, error.message)             } else if (redirectlocation) {                 res.redirect(302,                              redirectlocation.pathname +                              redirectlocation.search)             } else if (renderprops) {                 let html = rendertostring(<routingcontext {...renderprops} />);                 let page = swig.renderfile('views/index.html', { html: html });                 res.status(200).send(page);             } else {                 res.status(404).send('not found');             }     }); }); 

when inspect client-side logs see following warning before error:

warning: react.createelement: type should not null or undefined. should string (for dom elements) or reactclass (for composite components).

and actual error happens in third line of autogeneratewrapperclass function in reactdefaultinjection module.

function autogeneratewrapperclass(type) {   return reactclass.createclass({     tagname: type.touppercase(),     render: function() {       return new reactelement(         type,         null,         null,         null,         null,         this.props       );     }   }); } 

in experience happens when 1 of components null or undefined.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -