-1

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?

unknownmx
  • 29
  • 5

2 Answers2

0

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')
)
huMpty duMpty
  • 13,481
  • 12
  • 52
  • 88
0

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
unknownmx
  • 29
  • 5