docs/src/docs/react-intl/upgrade-guide-4.x.mdx
new IntlMessageFormat('a<b>strong</b>').format({
b: (...chunks) => <strong>{chunks}</strong>,
})
{placeholder} syntax for that.<link>. This effectively means you don't need to polyfill DOMParser in Node anymore.FormattedHTMLMessage & intl.formatHTMLMessage have been removed since FormattedMessage now fully supports embedded HTML tag.FormattedHTMLMessage & intl.formatHTMLMessage were originally created when React was fairly new. These components helped ease migration over from raw HTML to JSX. Given that current popularity of React right now and the fact that FormattedMessage allow rendering embedded HTML tag, this is no longer needed.In order to restore the old behavior of FormattedHTMLMessage & intl.formatHTMLMessage, we suggest you use the rich text format feature as below:
Old way:
intl.formatHTMLMessage('This is a <a href="foo">link</a>')
New way:
intl.formatMessage('This is a <a>link</a>', {
a: (...chunks) => sanitizeHTML(`<a href="foo">${chunks.join('')}</a>`),
})
This forces developers to always sanitize their rendered HTML & chunks, thus minimizing XSS.