Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript ReactJS – Trying to set state using time delay Reply To: ReactJS – Trying to set state using time delay

#240474
tomek
Participant

Hi,

try this:

    delayState: function() {
        setTimeout(() => {
            this.setState({
            clicked: false
          })
        }, 2000);
    },

I am using an arrow function here, so setTimeout won’t carry its this inside the body.