Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
| 'defaultLocale'
| 'defaultFormats'
| 'onError'
| 'timeZone'
>,
state: Formatters,
messageDescriptor: MessageDescriptor = {id: ''},
values: Record<
string,
PrimitiveType | React.ReactElement | FormatXMLElementFn
> = {}
): string | React.ReactNodeArray {
const {id, defaultMessage} = messageDescriptor;
// `id` is a required field of a Message Descriptor.
invariant(!!id, '[React Intl] An `id` must be provided to format a message.');
const message = messages && messages[id];
formats = deepMergeFormatsAndSetTimeZone(formats, timeZone);
defaultFormats = deepMergeFormatsAndSetTimeZone(defaultFormats, timeZone);
let formattedMessageParts: Array = [];
if (message) {
try {
const formatter = state.getMessageFormat(message, locale, formats, {
formatters: state,
});
formattedMessageParts = formatter.formatHTMLMessage(values);
} catch (e) {
onError(
createError(
constructor(props: Props) {
super(props);
invariant(
!props.updateIntervalInSeconds || !!(props.updateIntervalInSeconds && canIncrement(props.unit)),
'Cannot schedule update with unit longer than hour'
);
}
export function invariantIntlContext(intl?: any): asserts intl {
invariant(
intl,
'[React Intl] Could not find required `intl` object. ' +
' needs to exist in the component ancestry.'
);
}