Skip to content

addRecommendationListener()

Function@tryyoursize/react-native

Calls listener now (once known) and on every change. Returns { remove }.

function addRecommendationListener(product: string, listener: (r: Recommendation) => void): { remove(): void }
productstringRequired

Your product ID or SKU.

listener(r: Recommendation) => voidRequired

Called now (once known) and on every change.

{ remove(): void }: { remove() }.

useEffect(() => {
const sub = addRecommendationListener("SKU-123", (rec) => {
if (rec.status === "ready" && !touched) setSize(rec.size);
});
return () => sub.remove();
}, []);

Was this page helpful?