Preact
Preact’in API’si React ile uyumludur. Entegrasyon aynı deseni takip eder — uygulama başlangıcında load() fonksiyonunu bir kez çağırın, ardından JSX içinde <wink-*> etiketlerini kullanın.
@wink/elements npm paketi TypeScript tipleriyle CDN paketini yükleyin ve kurun.
Kurulum
Section titled “Kurulum”npm install @wink/elementsUygulama başlangıcında bir kez yükleyin
Section titled “Uygulama başlangıcında bir kez yükleyin”import { useEffect } from 'preact/hooks';import { load } from '@wink/elements';
export function App() { useEffect(() => { load({ clientId: import.meta.env.VITE_WINK_CLIENT_ID }); }, []);
return <YourRoutes />;}JSX içinde kullanın
Section titled “JSX içinde kullanın”export function HotelsPage() { return ( <main> <wink-content-loader layout="HOTEL" id="YOUR_LAYOUT_ID" /> <wink-lookup /> </main> );}TypeScript — JSX intrinsics bildirin
Section titled “TypeScript — JSX intrinsics bildirin”Preact’in JSX isim alanı React’ten ayrıdır. preact/src/jsx.d.ts dosyasını genişletin:
import type { WinkContentLoaderAttributes, WinkLookupAttributes, WinkSearchButtonAttributes, WinkAccountButtonAttributes, WinkItineraryButtonAttributes, WinkShoppingCartButtonAttributes, WinkAppLoaderAttributes,} from '@wink/elements';
declare module 'preact' { namespace JSX { interface IntrinsicElements { 'wink-content-loader': WinkContentLoaderAttributes & preact.JSX.HTMLAttributes<HTMLElement>; 'wink-lookup': WinkLookupAttributes & preact.JSX.HTMLAttributes<HTMLElement>; 'wink-search-button': WinkSearchButtonAttributes & preact.JSX.HTMLAttributes<HTMLElement>; 'wink-account-button': WinkAccountButtonAttributes & preact.JSX.HTMLAttributes<HTMLElement>; 'wink-itinerary-button': WinkItineraryButtonAttributes & preact.JSX.HTMLAttributes<HTMLElement>; 'wink-shopping-cart-button': WinkShoppingCartButtonAttributes & preact.JSX.HTMLAttributes<HTMLElement>; 'wink-app-loader': WinkAppLoaderAttributes & preact.JSX.HTMLAttributes<HTMLElement>; } }}preact/compat ile Preact
Section titled “preact/compat ile Preact”React’i preact/compat olarak alias yapıyorsanız, React JSX bildirimlerini kullanın:
// /integrations/react içindeki React JSX bildirimi kullanılır// — preact/compat React'in JSX isim alanını yeniden dışa aktarır