getMessageGetter() function

Given a MessageContext instance, returns a message getter function, which may have a preset root id path, locale, and/or base parameters for message functions.

The returned function takes two parameters (msgId, msgParams), which will extend any values set by the hook’s arguments.

Signature:

export declare function getMessageGetter(context: MessageContext, rootId?: string | string[], { baseParams, locale }?: MessageGetterOptions): (id?: string | string[], params?: Record<string, unknown>) => any;

Parameters

Parameter Type Description
context MessageContext The MessageContext instance
rootId string | string[] (Optional) The key or key path of the message or message object. If empty or [], matches the root of the messages object
{ baseParams, locale } MessageGetterOptions (Optional)

Returns:

(id?: string | string[], params?: Record<string, unknown>) => any