iframemanager icon indicating copy to clipboard operation
iframemanager copied to clipboard

Create reset function for re-render issues

Open icetee opened this issue 1 year ago • 1 comments

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])
...

icetee avatar May 05 '24 11:05 icetee

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.

stale[bot] avatar Jun 06 '24 03:06 stale[bot]