React-Route没有匹配任何路由

时间:2018-08-01 03:04:06

标签: reactjs react-router react-redux react-router-redux

我一步一步地遵循this tutorial,但是当我运行“ npm run start”时,出现下一个错误:

  

警告:[反应路由器]位置“ / todolist”与任何路由都不匹配

有什么建议可以解决?

2 个答案:

答案 0 :(得分:0)

似乎您缺少路线定义。

在您的index.js中

protected override void OnSleep()
{
    CommonModel dataList = GetCommonModel();

    foreach(var data in dataList)
    {
        if (await ProcessDataAsync(data))
        {
            UpdateDataModel(data); 
            // I need to know that sent data was updated on server successfully. 
            // In this case ProcessDataAsync returns true
        }
    }
}

答案 1 :(得分:0)

我所做的是在src / routes / index.js中定义我的路由,如下所示:

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