Skip to content

Latest commit

 

History

History
32 lines (22 loc) · 2.66 KB

File metadata and controls

32 lines (22 loc) · 2.66 KB
title MessageProviderProps
parent @messageformat/react
grand_parent API Reference

MessageProviderProps interface

Signature:

export interface MessageProviderProps 

Properties

Property Modifiers Type Description
children ReactNode
context? MessageContext (Optional)
debug? 'error' | 'warn' | ((msg: string) => unknown) (Optional)
locale? string (Optional) A key for the locale of the given messages. If uset, will inherit the locale from the parent context, or ultimately use en empty string.
merge? MessageContext['merge'] (Optional) By default, top-level namespaces defined in a child MessageProvider overwrite those defined in a parent. Set this to _.merge or some other function with the same arguments as Object.assign to allow for deep merges.
messages MessageObject A hierarchical object containing the messages as boolean, number, string or function values.
onError? 'error' | 'silent' | 'warn' | ((error: MessageError) => unknown)

(Optional) What to do on errors; most often called if a message is not found.

- "silent": Ignore the error; use the message's id as the replacement message.

- "error": Throw the error.

- "warn" (default): Print a warning in the console and use the message's id as the replacement message.

- (error) => any: A custom function that is called with an Error object with code: string and path: string[] fields set. The return falue is used as the replacement message.

pathSep? string | null (Optional) By default, . in a <Message id> splits the path into parts, such that e.g. 'a.b' is equivalent to ['a', 'b']. Use this option to customize or disable this behaviour (by setting it to null).