useEffect(() => {
// I've initiated Calendly in this effect
}, [])
console.log(window.Calendly)
I got undefined when I print window.Calendly, but when I print just window, I got an object contains Calendly.
Effects run after rendering. So you're logging first, and then setting up window.Calendly
later.
When you switch to logging window
, you're now logging an object. The developer tools do not evaluate what's in that object until you click to inspect it. So by the time you click, window.Calendly
exists, but it didn't exist when the log statement ran.