2017-10-15 47 views
0

反應組件上的UI。我有一個<BottomNavigationItem />組件。這實際上呈現爲<button>。我怎樣才能讓它呈現/導航到一個URL?Material-UI BottomNavigationItem URL

class FooterNavigation extends Component { 
    state = { 
    selectedIndex: 0, 
    }; 

    select = (index) => this.setState({selectedIndex: index}); 

    render() { 
    return (
     <footer className="mdl-mini-footer"> 
      <Paper zDepth={1}> 
      <BottomNavigation selectedIndex={this.state.selectedIndex}> 
      <BottomNavigationItem 
       label="Reviews" 
       icon={reviewIcon} 
       onClick={() => this.select(0)} 
      /> 
      </BottomNavigation> 
      </Paper> 
     </footer> 
    ); 
    } 
} 

回答

0

簡單的,你可以再補充containerElement={<Link to="/home"/>}不要忘了從react-router-dom

導入Link因此,這將是這樣的:

<BottomNavigationItem 
       containerElement={<Link to="/home"/>} 
       label="Reviews" 
       icon={reviewIcon} 
       onClick={() => this.select(0)} 
      />