Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create reset function for re-render issues #55

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

icetee
Copy link

@icetee icetee commented May 5, 2024

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

Signed-off-by: Horváth Tamás András <htomy92@gmail.com>
@icetee icetee requested a review from orestbida as a code owner May 5, 2024 11:38
Copy link

stale bot commented Jun 6, 2024

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 stale bot added the stale label Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant