Money Component
The Money component renders a string representing monetary values according to the locale set in the AirsokoProvider component.
Usage
import React from "react";
import { Money } from "@airsoko/react";
const MyComponent = () => {
const moneyData = {
amount: "10.99",
currencyCode: "USD",
};
return <Money data={moneyData} />;
};
export default MyComponent;Props
| Name | Type | Default | Description |
|---|---|---|---|
as | ElementType | 'div' | An HTML tag or React component to be rendered as the base element wrapper. |
data | MoneyV2 | An object with fields that correspond to the Storefront API's MoneyV2 object. | |
withoutCurrency | boolean | Whether to remove the currency symbol from the output. | |
withoutTrailingZeros | boolean | Whether to remove trailing zeros (fractional money) from the output. | |
measurement | UnitPriceMeasurement | A UnitPriceMeasurement object. | |
measurementSeparator | ReactNode | '/' | Customizes the separator between the money output and the measurement output. Defaults to '/'. |
otherProps | Object | Any other props accepted by the specified HTML tag or React component. |
Notes
- Ensure that the
Moneycomponent receives a validdataprop that hasamountandcurrencyCode. - The
Moneycomponent internally utilizes theuseMoneyhook to process thedataprop. - If the
dataprop is invalid, an error will be thrown. - The
measurementprop is optional and is used for displaying additional measurement information alongside the money value.