[英]React-bootstrap tabs: Warning: In the context of a `<TabContainer>`, `<NavItem>`s are given generated `id` and `aria-controls` attributes
I'm getting this warning whenever the navbar is loaded for me. 每当为我加载导航栏时,我都会收到此警告。 I have no idea what to do with it or what it means - i've tried adding a parent div with no luck. 我不知道该怎么办或意味着什么-我尝试添加没有运气的父div。 The generateChildId
property according to their documentation only takes functions as input. 根据其文档的generateChildId
属性仅将函数作为输入。 Super confusing. 超级混乱。
Full warning: 完整警告:
Warning: In the context of a `<TabContainer>`, `<NavItem>`s are given generated `id` and `aria-controls` attributes for the sake of proper component accessibility. Any provided ones will be ignored. To control these attributes directly, provide a `generateChildId` prop to the parent `<TabContainer>`.
For the sake of it, the navbar + tabs work completely as intended. 为此,导航栏+选项卡完全按预期工作。 It simply throws this warning constantly in the console. 它只是在控制台中不断发出此警告。
Example used from here , sample code: 从这里使用的示例,示例代码:
<Tab.Container id="tabs-with-dropdown" defaultActiveKey="first">
<Row className="clearfix">
<Col sm={12}>
<Nav bsStyle="tabs">
<NavItem eventKey="first">
Tab 1
</NavItem>
<NavItem eventKey="second">
Tab 2
</NavItem>
<NavDropdown eventKey="3" title="Dropdown" id="nav-dropdown-within-tab">
<MenuItem eventKey="3.1">Action</MenuItem>
<MenuItem eventKey="3.2">Another action</MenuItem>
<MenuItem eventKey="3.3">Something else here</MenuItem>
<MenuItem divider />
<MenuItem eventKey="3.4">Separated link</MenuItem>
</NavDropdown>
</Nav>
</Col>
<Col sm={12}>
<Tab.Content animation>
<Tab.Pane eventKey="first">
Tab 1 content
</Tab.Pane>
<Tab.Pane eventKey="second">
Tab 2 content
</Tab.Pane>
<Tab.Pane eventKey="3.1">
Tab 3.1 content
</Tab.Pane>
<Tab.Pane eventKey="3.2">
Tab 3.2 content
</Tab.Pane>
<Tab.Pane eventKey="3.3">
Tab 3.3 content
</Tab.Pane>
<Tab.Pane eventKey="3.4">
Tab 3.4 content
</Tab.Pane>
</Tab.Content>
</Col>
</Row>
</Tab.Container>
);
Googling this warning provides nearly nothing 谷歌搜索此警告几乎没有提供任何帮助
I think is because you provided an id
to NavDropdown
element. 我认为是因为您为NavDropdown
元素提供了一个id
。
The warning is probably displaying a wrong message because it doesn't expect such item as child of Nav
. 该警告可能显示错误消息,因为它不希望使用Nav
子项之类的项目。
BTW: why not wrapping it inside a NavItem
? 顺便说一句:为什么不将其包装在NavItem
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.