Ir al contenido

useTryYourSize()

Esta página aún no está disponible en tu idioma.

Hook@tryyoursize/react

The TryYourSize client, or null until it has loaded.

function useTryYourSize(): TryYourSizeClient | null

TryYourSizeClient | null: The client, or null until it has loaded. Throws outside a provider.

function SizeBadge({ sku }: { sku: string }) {
const tys = useTryYourSize();
const [size, setSize] = useState<string | null>(null);
useEffect(() => {
tys?.recommendation(sku).then((r) => setSize(r.status === "ready" ? r.size : null));
}, [tys, sku]);
return size ? <span>Your size: {size}</span> : null;
}

¿Te ha resultado útil esta página?