reactjs - react router nested components issue -
i have following code -
class app extends component { render() { return ( <router> <switch> <mainpage> <route exact path="user" component={error}/> </mainpage> </switch> </router> ) } }
right mainpage rendered every url , understand why, lets want render pages. how can wrap in order done?
let's want show mainpage /user
, /member
, while /anonymous
shown without mainpage:
class app extends component { render() { return ( <router> <switch> <route path="/anonymous" component={anonymous} /> <route path="/" component={mainpage} /> </switch> </router> ) } } class mainpage extends component { render() { return ( <div> .... // place original code print `mainpage` here <route path="/user" component={user}/> <route path="/member" component={member}/> </div> ) } }
Comments
Post a Comment