I am trying to use 'setTimeout' to run 'window.open' function after certain period of time. If I calculate the time difference with the parent's property and then use the output for 'setTimeout', the 'window.open' function runs immediately. However, if I just give a number to the variable 'diffms', it works fine. I am using react and how can I fix this problem?
// const diffms = 10000;
const diffms = moment(this.props.schedule.time).diff(moment());
setTimeout(() => {
window.open("https://www.google.com");
}, diffms);