[react-intl] FormattedMessage children prop (#24670)

This commit is contained in:
Omar Diab 2018-04-09 10:42:41 -07:00 committed by Mohamed Hegazy
parent 710de9e694
commit ea718d99b4
2 changed files with 8 additions and 0 deletions

View File

@ -142,6 +142,7 @@ declare namespace ReactIntl {
interface Props extends MessageDescriptor {
values?: {[key: string]: MessageValue | JSX.Element};
tagName?: string;
children?: (formattedMessage: string[]) => React.ReactNode;
}
}
class FormattedMessage extends React.Component<FormattedMessage.Props> { }

View File

@ -143,6 +143,13 @@ class SomeComponent extends React.Component<SomeComponentProps & InjectedIntlPro
values={{ blank: null, empty: undefined }}
tagName="div" />
<FormattedMessage
id="test"
description="Test"
>
{(text) => <div className="messageDiv">{text}</div>}
</FormattedMessage>
<FormattedHTMLMessage
id="test"
description="Test"