码迷,mamicode.com
首页 > Web开发 > 详细

[React Intl] Render Content with Markup Using react-intl FormattedHTMLMessage

时间:2017-07-28 20:59:06      阅读:442      评论:0      收藏:0      [点我收藏+]

标签:book   ring   long   att   hang   data   tran   possible   his   

In this lesson, we’ll use the react-intl FormattedHTMLMessage component to display text with dynamic values along with other HTML elements to create emphasis on a piece of text.

NoteFormattedHTMLMessage should be used sparingly because react-intlcannot intelligently update the component by re-rendering only pieces that have changed. Instead, it has to re-render the entire component. If possible, use a FormattedMessage component instead, and wrap that component with HTML markup.

 

For example we have the translation data as such:

  ‘en-US‘: {
    detail: {
      window: ‘<small><em>All {numMerchants} links open in a new window.</em></small>‘,
    }
}

It is a embbed HTML.

 

To use it we need to import ‘FormattedHTMLMessage‘:

<FormattedHTMLMessage id="detail.window" values={{numMerchants: book.merchants.length}} />

 

[React Intl] Render Content with Markup Using react-intl FormattedHTMLMessage

标签:book   ring   long   att   hang   data   tran   possible   his   

原文地址:http://www.cnblogs.com/Answer1215/p/7252346.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!