Easier way to to disable link in React?

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

I want to disable Link in some condition:

render() {
    return (
  • {this.props.canClick ? Test
  • 7条回答
    •  没有蜡笔的小新
      2021-01-02 05:32

      You could just set set the link's onClick property:

      render () {
        return(
          
    • { this.props.notClickable ? event.preventDefault() }>Link : Link }
    • ); };

      Then disable the hover effect via css using the cursor property.

      .disabledCursor { 
        cursor: default;
      }
      

      I think that should do the trick?

    提交回复
    热议问题