Problems with immediate execution of setTimeout

when I was using react-native to develop Android app, I encountered the problem of immediate execution of setTimeout. I found a lot of information on the Internet and tried to no avail, so I came to ask for help. No, no, no.

here is my code

    _heightAnimate = () => {
        let that = this;
        setTimeout(function () {
            that.exChangeToImageDetails()
        }, 10000);
    }

    exChangeToImageDetails = () => {
        this.props.exChangeSwiper(1, true)
    }
    
    //_heightAnimate()exChangeToImageDetails

is there something wrong with my writing? Is there a good solution?

Jun.30,2021

is fine as far as the code is concerned. You can print it in the timer and exChangeToImageDetails function to see when it is running and whether it is caused by the timer running. Or you also called the function


I tried to change this.props.exChangeSwiper (1, true) to console.log ('123')
this is no problem, your code should also be no problem, problems may occur in this.props.exChangeSwiper (1, true) this method.
or where else your code affects this side. Take a closer look at

Menu