2

All the other redirects (conditional redirects) work perfectly but not the one in the button (using <Link> works perfectly fine) Doesnot redirect when the button is clicked

I have implemented one more redirect in another page on a button click and it works perfectly fine

 render() {
    const { props } = this

    if (this.props.isauthed) {
      if (this.state.usertype == 'user') {
        return <Redirect to='/user' />
      } else {
        if (this.state.usertype == 'customer') {
          return <Redirect to='/customer' />
        } else {
          return (

            <div >
              <Button onClick={() => {<Redirect to='/user' />}}>click here if you are a user</Button>

              <Button onClick={() => {<Redirect to='/customer'/>}}>click here if you are a customer</Button>

            </div>
          )
        }
      }
    } else {
      return <Redirect to='/login' />
    }

  }

0 Answers0