In some cases, you might need to pass a string from your intl messages.js file as a prop to a component. Instead of using react-intl components (which generate markup), we’ll use the injectIntl higher order component provided by react-intl. This will provide just the string we’re looking for, make the prop simpler, and avoid creating unnecessary DOM elements.

We’ll also use props passed to the component from the Higher Order Component to clean up some redundant code.

import React from 'react';
import { injectIntl, FormattedMessage, FormattedHTMLMessage, FormattedRelative , FormattedTime, FormattedNumber } from 'react-intl';
import {meanBy, round, sortBy} from 'lodash'; import books from '../books.json'; const BookDetail = ({match, intl}) => { return (
<div className="BookDetail">
....
<textarea placeholder={intl.formatMessage({
id: 'detail.inputPlaceholder'
})} cols="30" rows="10"></textarea>
</div>
)
} export default injectIntl(BookDetail);

最新文章

  1. C#微信公众号接口开发实例-高级接口-申请带参数的二维码
  2. 1.4 Service
  3. Excel文件导入SQL Server数据库表
  4. HDU 1728 逃离迷宫
  5. QVW中实现日期区间的选择功能!
  6. Android仿微信SlideView聊天列表滑动删除效果
  7. 05 Android强制设置横屏或竖屏/全屏
  8. (一一三)使用系统自带框架操作SQLite3数据库
  9. Aliyun上Linux服务器挂载数据盘及速度测试
  10. 【朝花夕拾】四大组件之(一)Broadcast篇
  11. Do-Now—团队冲刺博客三
  12. 校园服务nabcd需求分析
  13. php类自动加载
  14. proc/net/dev实时网速统计实例【转】
  15. 新建一个self hosted Owin+ SignalR Project(1)
  16. mysql 数据库操作 数据库的增删改查
  17. nginx命令行参数
  18. Serializers序列化组件
  19. 数据库批量操作中SqlParameter参数传递的问题
  20. Facebook人工智能实验室的前世今生

热门文章

  1. 指尖上的电商---(10)SolrAdmin中加入多核
  2. POJ 3040 贪心
  3. POJ 2437 贪心+priority_queue
  4. 如何让hudson的两个job共用一个svn工作目录
  5. 利用日志文件恢复MYSQL数据库
  6. 搭建Spark源码研读和代码调试的开发环境
  7. DG的数据保护模式
  8. C/C++(基础-运算符详解)
  9. dp之完全背包 hdu--2159一维数组做法
  10. HDU——T 2594 Simpsons’ Hidden Talents