I am using react-bootstrap version 0.32.4, I can't update the version, that will bring up many changes.
I want to have a tooltip info showing for 4 seconds on page load and then it should hide, after that the tool tip info should be shown on hover.
Below is the code:
import React from "react";
import "./styles.css";
import { Button, Tooltip, OverlayTrigger } from "react-bootstrap";
import { render } from "react-dom";
class App extends React.Component {
constructor(props){
super(props);
this.state = {
show: true
}
}
getTooltip = () => {
return <Tooltip id="tooltip">this is tooltip text</Tooltip>;
};
componentDidMount() {
console.log("ran")
setTimeout(function() {
this.setState({show: false})
}.bind(this), 4000);
}
render(){
console.log(`running for componet did update: ${this.state.show}`)
return (
<>
<OverlayTrigger
trigger={['hover', 'focus']}
defaultShow={this.state.show}
placement="right"
overlay={this.getTooltip()}
>
<Button>Click me!</Button>
</OverlayTrigger>
</>
);
}
}
export default App;
I am trying to use defaultShow but it is not doing anything. How can I achieve this functionality with react-bootstrap version 0.32.4
Below is the link to code sandbox: