useGlobalize
is a hook which gives access to the Globalize object. You can then destructure any formatters you need within the component.
import { useGlobalize } from 'react-native-globalize';
const ExampleComponent = () => {
const { formatDate, formatMessage } = useGlobalize();
return (
<Text>
{formatMessage('welcome', {
date: formatDate(new Date(), { date: 'long' }),
})}
</Text>
)
};
The following functions and utilities are available on the Globalize object returned by useGlobalize
: