我正在尝试在 create-reat-app 中使用 react-router 和 reactstrap。在路由页面中,我需要使用 reactstrap 的状态,因此我将路由器从变量转换为类。我收到此警告:警告: validateDOMNesting(...):
<a> cannot appear as a descendant of <a>.
我不知道该怎么做?,我需要使用 reactstrap 来设置路由器导航的样式,所以我做了你在下面看到的。
由于很多原因,这不起作用:
<NavLink componentClass={Link} href="/contact" to="/contact" active={location.pathname === '/contact'}>anywords</NavLink>
Run Code Online (Sandbox Code Playgroud)
<Navbar dark id="RouterNavbar" expand="md">
<NavbarBrand id="NavBrand"href="#x"><ul>(a bunch of li not relevant)</ul></NavbarBrand>
<NavbarToggler id="NavBarToggler" onClick={this.toggle1.bind(this)} />
<Collapse isOpen={this.state.isOpen1} navbar>
<Nav className="ml-auto" navbar>
<NavItem>
<NavLink href="#x"><Link id="RouterNavLink" style={None} to="/contact">anywords</Link></NavLink>
</NavItem>
(then just more of the above)
Run Code Online (Sandbox Code Playgroud)
除了几个 li 随机靠近彼此,我有时不得不刷新页面而不是正常行为(自动刷新)和我在控制台中收到的警告消息,没有什么不好的事情发生,但是当我读到这个的时候问题我发现我不应该这样做。