reactjs - How to render Multiple NavBar in react -
i new react. trying render multiple navbar in page 1 beneath other. navbar code looks following
import react, { component, proptypes } 'react'; import { navbar, nav, navitem } 'react-bootstrap'; import { linkcontainer } 'react-router-bootstrap'; import {connect} 'react-redux'; import * actioncreators '../action_creators'; import subnav './subnavbar.jsx'; class mainnav extends component { constructor(props) { super(props); this.state = { loggedin: 1, }; } render() { return ( <div> <navbar inverse fixedtop collapseonselect> <navbar.header> <navbar.brand> <a href="/">sportsspot</a> </navbar.brand> <navbar.toggle /> </navbar.header> <navbar.collapse> <nav> <linkcontainer to="/nfl" activeclassname="active"> <navitem onclick={this.props.getcurrentnflnews} eventkey={1}>nfl</navitem> </linkcontainer> <linkcontainer to="/mlb" activeclassname="active"> <navitem onclick={this.props.getcurrentmlbnews} eventkey={2}>mlb</navitem> </linkcontainer> <linkcontainer to="/nba" activeclassname="active"> <navitem onclick={this.props.getcurrentnbanews} eventkey={3}>nba</navitem> </linkcontainer> <linkcontainer to="/nhl" activeclassname="active"> <navitem onclick={this.props.getcurrentnhlnews} eventkey={4}>nhl</navitem> </linkcontainer> </nav> <nav pullright> <linkcontainer to="/login"> <navitem>login</navitem> </linkcontainer> <linkcontainer to="/signup"> <navitem>sign up</navitem> </linkcontainer> </nav> </navbar.collapse> </navbar> <subnav/> // adding subnavbar code here <div classname="content"> {this.props.children} </div> </div> ) } } mainnav.proptypes = { children: proptypes.element.isrequired, getcurrentnhlnews : proptypes.func.isrequired, getcurrentmlbnews : proptypes.func.isrequired, getcurrentnflnews : proptypes.func.isrequired, getcurrentnbanews : proptypes.func.isrequired, }; export default connect(null,actioncreators)(mainnav);
and subnavbar has following code
import react, { component} 'react'; import { navbar, nav, navitem } 'react-bootstrap'; import { linkcontainer } 'react-router-bootstrap'; import {connect} 'react-redux'; import * actioncreators '../action_creators'; class subnav extends component { render() { return ( <navbar collapseonselect> <navbar.header> <navbar.brand> nfl </navbar.brand> <navbar.toggle /> </navbar.header> <navbar.collapse> <nav> <linkcontainer to="/scores"> <navitem>scores</navitem> </linkcontainer> <linkcontainer to="/schedules"> <navitem>schedule</navitem> </linkcontainer> <linkcontainer to="/standings"> <navitem >standings</navitem> </linkcontainer> <linkcontainer to="/stats"> <navitem>stats</navitem> </linkcontainer> <linkcontainer to="/teams"> <navitem>teams</navitem> </linkcontainer> </nav> </navbar.collapse> </navbar> ); } } export default connect(null,actioncreators)(subnav);
i want render subnavbar beneath main navbar. tried importing subnavbar.jsx in main navbar , added doesn't seem render. adding routes code below
const routes =<div> <mainnav> <app> <switch> <route exact path="/" component={homepagecontainer}/> <route exact path="/nfl" component={subsportshomepagecontainer}/> <route exact path="/nhl" component={subsportshomepagecontainer}/> <route exact path="/nba" component={subsportshomepagecontainer}/> <route exact path="/mlb" component={subsportshomepagecontainer}/> <route path ="/login" component = {loginpage}/> <route path ="/signup" component = {signuppage}/> </switch> </app> </mainnav> <subnav> <switch> <route exact path="/scores" component={scores}/> <route exact path="/schedules" component={schedule}/> <route exact path="/standings" component={standings}/> <route exact path="/stats" component={stats}/> <route path ="/teams" component = {teams}/> </switch> </subnav> </div>
i know mistake committing. in advance
Comments
Post a Comment