Easier way to to disable link in React?

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

I want to disable Link in some condition:

render() {
    return (
  • {this.props.canClick ? Test
  • 7条回答
    •  感动是毒
      2021-01-02 05:43

      Just making the URL null seems to do the trick:

      const url = isDisabled ? null : 'http://www.stackoverflow.com';
      
      return (
        Click Me
      );
      

    提交回复
    热议问题