iframemanager
iframemanager copied to clipboard
Create reset function for re-render issues
The plugin cannot detect DOM changes, indeed keeps the previous one. This is a clean solution that does not affect the expected operation. There are cases when you need to reset the entire script, this helps. #48
Example:
import { useRouter } from 'next/router'
...
useEffect(() => {
// const cc = initCookieConsent()
const im = iframemanager()
setTimeout(() => {
im.run(...)
}, 1000) // Since it is not SSR, it is necessary to allow time for the client to render it
return () => {
im.reset() // stop observers, reset scoped variables
}
}, [router.asPath])
...
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.