我'm trying to use react-router v4 and for some reason when I change the routes using normal links and the Link components, the route doesn' t触发,但如果我直接在URL栏中访问或只是刷新页面,该路径中的组件将呈现该组件 . 检查后,我看到上下文已更新,但道具没有 . 如下图所示:
code-situation
从'/about'路径开始,单击'/projects'链接(关闭组件仍然在Switch内部,而不是更改Projects组件) . 路由定义如下:

<Switch>
    <Route exact path='/' component={Home}/>
    <Route path='/about' component={AboutMe}/>
    <Route path='/projects' component={Projects}/>
    <Route path='/contact' component={Contact}/>
    <Route component={NotFound} />
 </Switch>

我已经尝试过使用BrowserRouter,HashRouter和Router组件,也可以在Switch组件中包含/不包含路由(似乎没什么用) . 我已经在教程,文档,其他stackoverflow问题和回购问题中搜索了两天,到目前为止一无所获,所以我在这里! :)

我正在使用这些包:

  • 反应v15.5.4

  • react-router-dom v4.1.1

提前致谢! \ o