[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 Internationalization API, which react-intl depends on. In order to support these browsers, we’ll conditionally include an Intl polyfill using webpack require.ensure. This ensures only browsers that need the polyfill incur the extra load.
if (!window.Intl) {
require.ensure([
'intl',
'intl/locale-data/jsonp/en.js',
'intl/locale-data/jsonp/fr.js',
'intl/locale-data/jsonp/es.js'
], (require) => {
require('intl');
require('intl/locale-data/jsonp/en.js');
require('intl/locale-data/jsonp/fr.js');
require('intl/locale-data/jsonp/es.js');
runApp();
})
} else {
runApp();
}
function runApp() {
addLocaleData([...en, ...fr, ...es]);
let locale = (navigator.languages && navigator.languages[0])
|| navigator.language
|| navigator.userLanguage
|| 'en-US';
ReactDOM.render(
<IntlProvider locale={locale} messages={flattenMessages(messages[locale])}>
<App />
</IntlProvider>,
document.getElementById('root')
);
}
[React Intl] Use Webpack to Conditionally Include an Intl Polyfill for Older Browsers的更多相关文章
- [React] react+redux+router+webpack+antd环境搭建一版
好久之前搭建的一个react执行环境,受历史影响是webpack3.10.0和webpack-dev-server2.7.1的环境,新项目准备用webpack4重新弄弄了,旧的记录就合并发布了(在没有 ...
- react 后台(一)react + redux + react-route + webpack+ axios + antd+styled-components(替代less)
create-react-app my-admin 项目技术栈 react + redux + react-route + webpack+ axios + antd+styled-component ...
- react 后台(一) react + redux + react-route + webpack+ axios + antd + less
create-react-app 项目名称(项目失败,ant 的样式出不来) 项目技术栈 react + redux + react-route + webpack+ axios + less + a ...
- 如何扩展 Create React App 的 Webpack 配置
如何扩展 Create React App 的 Webpack 配置 原文地址https://zhaozhiming.github.io/blog/2018/01/08/create-react-a ...
- React报错之React hook 'useState' is called conditionally
正文从这开始~ 总览 当我们有条件地使用useState钩子时,或者在一个可能有返回值的条件之后,会产生"React hook 'useState' is called conditiona ...
- 从零开始配置TypeScript + React + React-Router + Redux + Webpack开发环境
转载请注明出处! 说在前面的话: 1.为什么不使用现成的脚手架?脚手架配置的东西太多太重了,一股脑全塞给你,我只想先用一些我能懂的库和插件,然后慢慢的添加其他的.而且自己从零开始配置也能学到更多的东西 ...
- webpack构建多页面react项目(webpack+typescript+react)
目录介绍 src:里面的每个文件夹就是一个页面,页面开发相关的组件.图片和样式文件就存放在对应的文件夹下. tpl:里面放置模板文件,当webpack打包时为html-webpack-plugin插件 ...
- react案例->新闻移动客户端--(react+redux+es6+webpack+es6的spa应用)
今天分享一个react应用,应在第一篇作品中说要做一个react+redux+xxx的应用.已经做完一部分,拿出来分享.github地址为:点我就可以咯~ 这里实现了一个新闻移动站的spa.本来想写p ...
- [React] Asynchronously Load webpack Bundles through Code-splitting and React Suspense
One approach to building high performance applications with webpack is to take advantage of code-spl ...
随机推荐
- Cisco Works 2000 网络管理软件安装、配置全过程
下面是在windows 2000 server 下安装ciscoworks 2000的过程.(附件中是标准avi格式文件,由于上传附件大小限制,更多内容见Sina播客) 浏览全部原创视频请见: htt ...
- jdbc的数据库驱动类DriverManager.getConnection()详解
1.Oracle8/8i/9i数据库(thin模式) Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); ...
- Codefroces Educational Round 26 837 C. Two Seals
C. Two Seals time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- WebMethod Description
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx https://www.cnblogs.com/wanganyi/p/72202 ...
- 【DRF分页】
目录 第一种 PageNumberPagination 查第n页,每页显示n条数据 第二种 LimitOffsetPagination 在第n个位置,向后查n条数据 第三种 CursorPaginat ...
- Android ImageView设置图片原理(上)
本文来自http://blog.csdn.net/liuxian13183/ ,引用必须注明出处! 首先关于图片加载到ImageView上,我们来讨论几个问题: 如下: imageView.setIm ...
- 洛谷 P3505 [POI2010]TEL-Teleportation
P3505 [POI2010]TEL-Teleportation 题目描述 King Byteasar is the ruler of the whole solar system that cont ...
- VMware虚拟机XP系统安装
转载:http://jingyan.baidu.com/article/54b6b9c00e2f452d593b4762.html
- actionBarTab-actionBarTab自定义 布局没法改变其中字体相对中间的位置
我们经常遇到对actionBarTab 进行操作的情况.现在记录修改它的样式的方法,已经如何自定义tab的显示布局 1.在你的theme主题中添加<item name="android ...
- 为什么会出现NoSQL数据库
为什么会出现NoSQL数据库 一.总结 一句话总结:sql不支持分布式且且有性能瓶颈且不支持分布式,不同NoSQL适合不同的场景 1."不同的NoSQL数据库只适合不同的场景"这句 ...