I want to disable Link in some condition:
render() {
return ({this.props.canClick ?
Test
A good solution is using onClick() with event object. just do this in your jsx:
this._onClick(e)}
and in your _onClick function:
_onClick = (e) => {
e.preventDefault()
}
Complete Example in React:
import React, { Component } from 'react'
import {Link} from 'react-router-dom'
export default class List extends Component {
_onClick = (e) => {
e.preventDefault()
}
render(){
return(
this._onClick(e)}
)
}
}