ข้ามไปยังเนื้อหา
Yuva subscribe hookเมนู

Yuva subscribe hook

A React hook over the useyuva headless client: the channel's public mailing lists, subscribing from a form with its form token, and the signed-in user's subscriptions with an identity token.

Loading

    ตัวอย่างทำงานด้วยข้อมูลตัวอย่าง ไม่ต้องใช้เครือข่ายหรือช่องทาง

    การติดตั้ง

    รันคำสั่งนี้ในโปรเจกต์ shadcn ไฟล์จะถูกคัดลอกไปเป็นโค้ดของคุณเอง

    Shell
    npx shadcn@latest add https://useyuva.com/r/use-yuva-subscribe.json

    การใช้งาน

    tsx
    import { useYuvaSubscribe } from "@/hooks/use-yuva-subscribe"
    
    const { lists, states, subscribe, setSubscribed } = useYuvaSubscribe({ server, channel })

    Props

    UseYuvaSubscribeOptions

    Propชนิด
    server?string
    channel?string
    client?YuvaClient
    identityToken?IdentityTokenSource | null
    lists?string[]

    YuvaSubscribeState

    Propชนิด
    inboxNamestring
    listsClientMailingList[]
    statesRecord<string, SubscriptionState | undefined>
    identifiedboolean
    loadingboolean
    errorunknown
    subscribe(input: YuvaSubscribeInput) => Promise<{ confirmation: boolean }>
    setSubscribed(listId: string, on: boolean, consentText: string) => Promise<SubscriptionState>

    ส่วนที่ต้องพึ่งพา

    การติดตั้งรายการนี้จะเพิ่มรายการต่อไปนี้ด้วย

    แพ็กเกจ npm