Change the tooltip text when a condition is true, at first displaying default tooltip text but once the changeToolTip function condition is true, change the text.
class Modal extends Component {
constructor() {
super();
this.state = {
show: false
};
this.showModal = this.showModal.bind(this);
this.hideModal = this.hideModal.bind(this);
}
showModal = () => {
this.setState({ show: true });
};
hideModal = () => {
this.setState({ show: false });
};
changeToolTip(){
if(sessionStorage.getItem("searchData") == null){
//change tooltip text
}
}
render() {
return (
<div>
<Modal show={this.state.show} handleClose={this.hideModal} />
<div data-toggle="tooltip"
data-class="search-tool-tip"
data-tip="this is before tooltip"
data-place="left" type="button" onClick={this.showModal}>
</div>
</div>
);
}
}