Format currency based on sales policy config.
Add "vtex.format-currency": "0.x"
to your dependencies.
import React from 'react'
import { FormattedCurrency } from 'vtex.format-currency'
function Foo() {
return <FormattedCurrency value={10} />
}
// <Fragment>
// $ 10.00
// </Fragment>
export default Foo
import React from 'react'
import { useIntl } from 'react-intl'
import { formatCurrency } from 'vtex.format-currency'
import { useRuntime } from 'vtex.render-runtime'
function Foo({ intl }) {
const { culture } = useRuntime()
const intl = useIntl()
const value = formatCurrency({ intl, culture, value: 10 })
return <span>{value}</span>
}
// <span>
// $ 10.00
// </span>
export default Foo