Callback loop with `NuxtTurnstile`
huang-julien opened this issue Β· comments
π The bug
When changing the page, the turnstile box isn't properly removed and causing and infinite loop.
to reproduce it on the reproduction,
- go to the form page
- load the turnstile iframes
- wait for it
- navigate back to the homepage
- open your console
- check your logs
π οΈ To reproduce
https://stackblitz.com/edit/github-cuqope?file=pages%2Findex.vue,pages%2Fform.vue
π Expected behaviour
we shouldn't have any warning log
βΉοΈ Additional context
I can take it, already fixed on my project :)
I noticed that too, recently. If you want feel free to submit a PR! β€οΈ
sure !
Waiting for fixing.
Oops for those interested here's the workaround atm,
within onBeforeUnmount
of the compoennt wrapper NuxtTurnstile
window.turnstile.remove(
str)
where str is the wrapper selector + div
ex:
onBeforeUnmount(() => {
window.turnstile.remove('#turnstile-wrapper div')
})
Turnstile remove
function either can receive the id of the widget or if it's a selector, look for the iframe of the widget within the selector