Hooks
Ez az oldal még csak angolul érhető el.
The hooks of @poltura/theme-sdk/editor.
Ezen az oldalon
import { … } from '@poltura/theme-sdk/editor';useIsEditing
Whether the page is drawn inside the customizer canvas.
useIsEditing(): booleanReturns: True on the customizer canvas, false on the live storefront.
Example
import { useIsEditing } from '@poltura/theme-sdk/editor';
export function EmptyHint({ count }: { count: number }) {
const editing = useIsEditing();
return count === 0 && editing ? <p>Add a product to this rail.</p> : null;
}usePreviewScenario
The choice the customizer's Data picker made for a preview domain.
usePreviewScenario(key: string): stringOutside the customizer it is always the domain's first choice, so branching on it costs nothing live.
Parameters
key: string: The domain key, a system one such ascartor one the theme declares.
Returns: The chosen value, or '' for a domain nobody declares.
Example
import { usePreviewScenario } from '@poltura/theme-sdk/editor';
export function Reviews({ count }: { count: number }) {
const shown = usePreviewScenario('reviews') === 'empty' ? 0 : count;
return <p>{shown} reviews</p>;
}