Message() function

<Message id [locale] [params] [...msgParams]>

The value of a message. May also be used with a render prop: <Message id={id}>{msg => {...}}</Message>.

Signature:

export declare function Message(props: MessageProps): any;

Parameters

Parameter Type Description
props MessageProps  

Returns:

any

Example

import React from 'react'
import { Message, MessageProvider } from '@messageformat/react'

const messages = { example: { key: ({ thing }) => `Your ${thing} here` } }

const Example = () => (
  <span>
    <Message id="example.key" thing="message" />
  </span>
) // 'Your message here'

export const App = () => (
  <MessageProvider messages={messages}>
    <Example />
  </MessageProvider>
)