IN ReactNative I have created one loader and this loader show and hide using by function. But when I am trying to call this function in setTimeout this is not working it returns me error like this -> this.showLoader is not a function. is undefined. But when I am tried to without setTimeout it working fine.
export default class ThirdScreen extends Component<Props> {
constructor(props) {
super(props)
this.state =
{
isLoading: false
}
this.showLoader = this.showLoader.bind(this);
}
componentDidMount() {
setTimeout(function(){
this.showLoader()
}, 1000);
//this.showLoader()
}
showLoader () {
this.setState({ isLoading: true });
}
hideLoader = () => {
this.setState({ isLoading: false });
}
}