getMessage() function

Given a MessageContext instance, fetches an entry from the messages object of the current or given locale. The returned value will be undefined if not found, or otherwise exactly as set in the MessageProvider props.


export declare function getMessage(context: MessageContext, id?: string | string[], locale?: string | string[]): unknown;


Parameter Type Description
context MessageContext  
id string | string[] (Optional) The key or key path of the message or message object. If empty or [], matches the root of the messages object
locale string | string[] (Optional) If set, overrides the current locale precedence as set by parent MessageProviders.