React
React 19+ תומך באופן מלא ברכיבים מותאמים אישית. React 18 והגרסאות הקודמות מעבירות רק מחרוזות בתור תכונות — השתמשו בתבנית העזר המוטיפית למטה כדי להישאר בטוחים בין הגרסאות.
@wink/elements npm package התקינו וטעינו את חבילת ה-CDN עם טיפוסי TypeScript.
npm install @wink/elementsטעינה פעם אחת בשורש האפליקציה
Section titled “טעינה פעם אחת בשורש האפליקציה”קראו ל-load() ברכיב העליון שלכם. הפונקציה אידמפוטנטית — בטוח לקרוא לה מספר פעמים.
import { useEffect } from 'react';import { load } from '@wink/elements';
export default function App() { useEffect(() => { load({ clientId: import.meta.env.VITE_WINK_CLIENT_ID }); }, []);
return <YourRoutes />;}שימוש ברכיבים ב-JSX
Section titled “שימוש ברכיבים ב-JSX”export default function HotelPage() { return ( <main> <wink-content-loader layout="HOTEL" id="YOUR_LAYOUT_ID" /> <wink-lookup /> </main> );}TypeScript — הכרזת JSX intrinsics
Section titled “TypeScript — הכרזת JSX intrinsics”React לא מכיר שמות של רכיבים מותאמים אישית כברירת מחדל. הוסיפו קובץ הכרזה פעם אחת כדי למנוע שגיאות טיפוס:
import type { WinkContentLoaderAttributes, WinkLookupAttributes, WinkSearchButtonAttributes, WinkAccountButtonAttributes, WinkItineraryButtonAttributes, WinkShoppingCartButtonAttributes, WinkAppLoaderAttributes,} from '@wink/elements';
declare module 'react' { namespace JSX { interface IntrinsicElements { 'wink-content-loader': WinkContentLoaderAttributes & React.HTMLAttributes<HTMLElement>; 'wink-lookup': WinkLookupAttributes & React.HTMLAttributes<HTMLElement>; 'wink-search-button': WinkSearchButtonAttributes & React.HTMLAttributes<HTMLElement>; 'wink-account-button': WinkAccountButtonAttributes & React.HTMLAttributes<HTMLElement>; 'wink-itinerary-button': WinkItineraryButtonAttributes & React.HTMLAttributes<HTMLElement>; 'wink-shopping-cart-button': WinkShoppingCartButtonAttributes & React.HTMLAttributes<HTMLElement>; 'wink-app-loader': WinkAppLoaderAttributes & React.HTMLAttributes<HTMLElement>; } }}העברת תכונות מוטיפיות (React 18 בטוח)
Section titled “העברת תכונות מוטיפיות (React 18 בטוח)”import type { WinkContentLoaderAttributes } from '@wink/elements';
const attrs: WinkContentLoaderAttributes = { layout: 'HOTEL', id: 'abc123', sort: 'POPULARITY',};
// Spread עובד ב-React 19; ב-React 18 כל הערכים מחרוזות בכל מקרהexport default function HotelCard() { return <wink-content-loader layout={attrs.layout} id={attrs.id} sort={attrs.sort} />;}