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的更多相关文章

  1. [React Intl] Render Content Based on a Number using react-intl FormattedMessage (plural)

    Using the react-intl FormattedMessage component, we’ll learn how to render content conditionally in ...

  2. [React Intl] Render Content with Placeholders using react-intl FormattedMessage

    Learn how to use react-intl to set dynamic values into your language messages. We’ll also learn how ...

  3. react之——render prop

    在react “从上至下的数据流原则” 背景下,常规的消息传递机制就是通过prop属性,把父级数据传递给子级,这样一种数据流通模式决定了——数据的接收方子组件要被”硬植入“进数据的数据的给予方父组件, ...

  4. [React] Render Text Only Components in React 16

    In this session we create a comment component to explore how to create components that only render t ...

  5. react解析: render的FiberRoot(三)

    react解析: render的FiberRoot(三) 感谢 yck: 剖析 React 源码解析,本篇文章是在读完他的文章的基础上,将他的文章进行拆解和加工,加入我自己的一下理解和例子,便于大家理 ...

  6. React components render order All In One

    React components render order All In One components render order / components lifecycle DOM tree ren ...

  7. React中render Props模式

    React组件复用 React组件复用的方式有两种: 1.render Props模式 2.高阶组件HOC 上面说的这两种方式并不是新的APi. 而是利用Raect自身的编码特点,演化而来的固定编码写 ...

  8. [React Intl] Use Webpack to Conditionally Include an Intl Polyfill for Older Browsers

    Some browsers, such as Safari < 10 & IE < 11, do not support the JavaScript Internationali ...

  9. React 源码剖析系列 - 不可思议的 react diff

      简单点的重复利用已有的dom和其他REACT性能快的原理. key的作用和虚拟节点 目前,前端领域中 React 势头正盛,使用者众多却少有能够深入剖析内部实现机制和原理. 本系列文章希望通过剖析 ...

随机推荐

  1. HH生病了(hpu1136)

    HH生病了 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 324  Solved: 90 [Submit][Status][Web Board] De ...

  2. 欢天喜地迎国庆,国产开源编程语言 RPP 1.87 公布!

    更新例如以下: 1.支持超级宏 2.修复bug 下载地址: https://github.com/roundsheep/rpp 超级宏能够随意定义语法,制约你的仅仅有想象力: void main() ...

  3. Java解析注解

    package com.itbuluoge.anno; import java.lang.reflect.Method; import java.util.ArrayList; import java ...

  4. Android学习笔记进阶20 之得到图片的缩略图

    <1>简介 之前往往是通过Bitmap.Drawable和Canvas配合完成,需要写一系列繁杂的逻辑去缩小原有图片,从而得到缩略图. 现在我给大家介绍一种比较简单的方法:(网上有) 在A ...

  5. 洛谷P2115 [USACO14MAR]破坏Sabotage

    题目描述 Farmer John's arch-nemesis, Farmer Paul, has decided to sabotage Farmer John's milking equipmen ...

  6. Kinect 开发 —— Hello,Kinect

    控制台输出深度数据: using System; using System.Collections.Generic; using System.Linq; using System.Text; usi ...

  7. pidof---查找指定名称的进程的进程号id号。

    pidof命令用于查找指定名称的进程的进程号id号. 语法 pidof(选项)(参数) 选项 -s:仅返回一个进程号: -c:仅显示具有相同“root”目录的进程: -x:显示由脚本开启的进程: -o ...

  8. python版 百度签到

    经常玩贴吧,刚学python ,所以自己弄了一个python版的签到程序.自己的东西总是最好的. 登陆模块参考的http://www.crifan.com/emulate_login_website_ ...

  9. Axios再记录

    一个基于Promise 用于浏览器和 nodejs 的 HTTP 客户端(可实现ajax的请求) 有关学习网址:https://www.tuicool.com/articles/eMb2yuY    ...

  10. ANSI-X99MAC算法和PBOC的3DES MAC算法

    仅仅要有标准的DES加密和解密算法.类似ANSI-X99MAC算法和PBOC3DES算法就非常好实现.他们都是用DES算法再经过一层算法实现的.实现原理看图就能看明确.3DES算法实现就更简单了.就是 ...