Skip to content

Commit

Permalink
fix(script): wait for mount again
Browse files Browse the repository at this point in the history
  • Loading branch information
dargmuesli committed Oct 14, 2024
1 parent b9378e5 commit 628381d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/runtime/components/NuxtTurnstile.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
/// <reference types="@types/cloudflare-turnstile" />
import { useScriptCloudflareTurnstile } from '../composables/turnstile'
import { useRuntimeConfig, ref, onBeforeUnmount, useScriptTriggerElement } from '#imports'
import { useRuntimeConfig, ref, onMounted, onBeforeUnmount, useScriptTriggerElement } from '#imports'
import type { ElementScriptTrigger } from '#nuxt-scripts'
const props = withDefaults(defineProps<{
Expand All @@ -27,7 +27,7 @@ const el = ref()
const unmountStarted = ref(false)
let id: string | undefined | null = undefined
let interval: NodeJS.Timeout
const { onLoaded, reset: _reset, remove } = useScriptCloudflareTurnstile({
const { render, reset: _reset, remove } = useScriptCloudflareTurnstile({
scriptOptions: {
trigger: useScriptTriggerElement({ trigger: props.trigger, el }),
},
Expand All @@ -47,8 +47,8 @@ const unmount = () => {
}
}
onLoaded((instance) => {
id = instance.render(el.value, {
onMounted(async () => {
id = await render(el.value, {
sitekey: props.siteKey || config.siteKey,
callback: (token: string) => emit('update:modelValue', token),
...props.options,
Expand Down

0 comments on commit 628381d

Please sign in to comment.