i'm following this tutorial step by step but when i run "npm run start" i get the next error:
Warning: [react-router] Location "/todolist" did not match any routes
Any advice to fix that?
i'm following this tutorial step by step but when i run "npm run start" i get the next error:
Warning: [react-router] Location "/todolist" did not match any routes
Any advice to fix that?
Seems you are missing the route definition.
In your index.js
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router, Route } from 'react-router-dom';
import { ToDoComponent,HomeComponent} from './components';
ReactDOM.render(
<Router>
<div>
<Route path="/" component={HomeComponent} />
<Route path="/todolist" component={ToDoComponent} />
</div>
</Router>,
document.getElementById('app')
)
What i did was define my route in src/routes/index.js, something like this:
import CoreLayout from '../layouts/PageLayout/PageLayout'
import Home from './Home'
import CounterRoute from './Counter'
import TodoListRoute from './TodoList'
/* Note: Instead of using JSX, we recommend using react-router
PlainRoute objects to build route definitions. */
export const createRoutes = (store) => ({
path : '/',
component : CoreLayout,
indexRoute : Home,
childRoutes : [
TodoListRoute(store), // Here's the trick
CounterRoute(store)
]
})
export default createRoutes