React-route-dom NavLink与SemanticUI无法正常工作

问题描述 投票:1回答:1

我正在努力实现这个目标。我已经到处搜索解决方案,但无法使其正常工作。

我在一个名为routes.jsx的单独文件中定义了我的路由,

enter image description here

在我的应用程序上,我正在导入我的路线和我的导航,这部分是可以的

enter image description here

但我的问题是,导航,当我点击,回家或者例如,浏览器把我带到那里,但是身体的内容没有更新,所以例如,当我点击导航链接时,我不知道在体内看到,我必须刷新浏览器才能看到它......

enter image description here enter image description here

javascript reactjs react-router react-router-dom
1个回答
3
投票

这是因为你使用两个独立的<BrowserRouter>s。它应该位于组件层次结构的最高级别。我会从RoutesNav中删除它并用它启动<App>

class App extends React.Component {

  render() {
   return (
      <BrowserRouter>
        ....
      </BrowserRouter>
   ); 
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.