2017-04-21 61 views
5

每當導航欄被加載時我。我不知道該怎麼處理它,或者說它的意思 - 我試過添加一個沒有運氣的父級div。根據文檔的generateChildId屬性僅將函數作爲輸入。超級混亂。React-bootstrap選項卡:警告:在`<TabContainer>的上下文中,`<NavItem>`給出生成的`id`和`aria-controls`屬性

已滿警告:

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>`. 

對於它的緣故,導航欄+標籤如預期完全工作。它只是不斷在控制檯中引發這個警告。

例中使用from here,示例代碼:

<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> 
); 

谷歌搜索這個警告提供幾乎沒什麼

+0

有趣的是,刪除'NavDropDown'使警告消失。我想這是因爲我沒有映射附加到MenuItems的事件密鑰?我只想要一個下拉式的佔位符。 – cbll

回答

1

我覺得是因爲你提供了一個idNavDropdown元素。

該警告可能顯示錯誤的信息,因爲它不指望Nav的孩子這樣的項目。

順便說一句:爲什麼不把它包裝在NavItem

相關問題