Easier way to to disable link in React?

前端 未结 7 391
逝去的感伤
逝去的感伤 2021-01-02 04:56

I want to disable Link in some condition:

render() {
    return (
  • {this.props.canClick ? Test
  • 相关标签:
    7条回答
    • 2021-01-02 05:54

      I think you should you atrribute to=null to set disable a link.

      <Link to=null />
      

      Your code:

      render() {
          return (<li>
              <Link to={this.props.canClick?'/goto-a-link':null} >Test</Link>
          </li>)  
      }
      
      0 讨论(0)
    提交回复
    热议问题