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

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -