Conditional ClassName in Router in React

You need to change how Route is defined from using component property to using render property. I have not included passing the props to Login component, I just showed how you can use the classes.

If necessary, then you should use <Login {...props}/>

<Route path="/signin" component={Login} />

to this

   <Route path="/signin" render={props => {
     return (
      <div className={classes.root}>
        <Login/>
      </div>
    )
   }}
  />

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top