reactjs - Want to route path in App.js according to a condition -


before routing component in project, first want first check condition , if condition satisfied have render page likewise. example in following code:

else {   return(           <div>       <route history={browserhistory}>         <route exact path="/set-geography" component={home} />       </route>     </div>   ); } 

i want render "/set-geography" once flow enters else trying following code:

else { window.location.href="/set-geography" return(         <div>       <route history={browserhistory}>         <route exact path="/set-geography" component={home} />     </route>   </div> ); } 

the routing taking place problem page not getting stable , page reloading again , again. in console not getting error. can me in rendering component. in advance :)

you can try use conditional rendering

      {unreadmessages.length > 0 &&         <h2>           have {unreadmessages.length} unread messages.         </h2>       } 

https://facebook.github.io/react/docs/conditional-rendering.html#inline-if-with-logical--operator


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -