0
<Route path="/dashboard" component={dashboard} >
  <Route path='/home' component={Home} /> 
  <IndexRoute  component={Myplan} />
  <Route path='/myprofile' component={MyProfile} />
  <Route path='/users' component={Users} />
  <Route path='/notifications' component={Notifications} />
  <Route path='/reports' component={Report} />
</Route>

In the routes.js file i am using IndexRoute to Myplan component In the entire Dashboard Component so when login It is redirecting to the Myplan component only

In the Dashboard Component

In the render Method I am rendering the components like this

{
validate!= 0 ? <li><Link to="/home" > Home <i className="fa fa-home"></i></Link></li> : null
}

{
validate!= 0 ? <li><Link to="/reports"> Analytics <i className="fa fa-line-chart"></i></Link></li> : null
}

<li><Link to="/dashboard"> My Plan <i className="fa fa-ticket"></i></Link></li>
<li><Link to="/myprofile" onClick={() => this.handleEdit(edituser.user)}> My Profile <i className="fa fa-ticket"></i></Link></li>

I Need the The Home component to be linked when the "validate!= 0" In the render i am checking like this, What is the right way to do dynamic routing based on condition check.

if(validate!= 0){
  return <Link to="/home" />
}
asiniy
  • 11,816
  • 6
  • 49
  • 117
siva
  • 19
  • 8

0 Answers0