Function useCurrencyFormatting

  • Preact hook that formats prices based on supplied currency with a fallback to the default currency.

    Should always be at the top of the component!

    Returns { format: (value: number, currency?: string) => string }

    • format: (value: number, currency?: string) => string
    import { useCurrencyFormatting } from '@nosto/preact'

    export default () => {
    const { format } = useCurrencyFormatting()

    return (

    <div class="product product-title">
    <span class="correct">
    {product.name}
    </span>
    </div>

    ...

    <div class="product price product-price">
    <span>{format(product.listPrice, product.priceCurrencyCode || "EUR")}</span>
    </div>
    )
    }