reactjs - Warning: Failed prop type: Invalid prop `component` supplied to `Route`. & Warning: [react-router] Location "/" did not match any routes -


i speak little engilsh,sorry first.

i have searched similar questions, not help. can't figure out happen myself, spend me 1 hours.

i start project latest yeoman & generator-react-webpack.

some error exist.in browser console.

warning: failed prop type: invalid prop `children` supplied to`router`. warning: [react-router] location "/" did not match routes 

here index.js.

import 'core-js/fn/object/assign'; import react 'react'; import reactdom 'react-dom'; import {router, route, hashhistory, indexroute} 'react-router';  import indexpage './components/indexpage'; import pages './components/pages';  reactdom.render((     <router history={hashhistory}>         <route path="/" component={indexpage} />         <route path="/pages" component={pages} />     </router> ), document.getelementbyid('webapp')); 

here indexpage.js.

import react, {component} 'react'; export default class indexpage extends component {     render() {         return (             <div>1234</div>         )     } } 

and here pages.js.

import react, {component} 'react'; export default class pages extends component {     render() {         return (             <div>9876</div>         )     } } 

checkout if filenames , import statements have correct spelling.

pages.js should pages.js
indexpage.js should indexpage.js

or change in import statements.. case-sensitive.

the docs says have wrap routes main router /

  <router history={browserhistory}>     <route path="/" component={app}>        <route path="about" component={about}/>       <route path="users" component={users}>         <route path="/user/:userid" component={user}/>       </route>       <route path="*" component={nomatch}/>      </route>   </router>    // main app component   const app = ({children}) => (      <div id="main-layout">{children}</div>   ) 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -