[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 ...
随机推荐
- ExtAspNet依据Grid导出Excel
protected void Button1_Click(object sender, EventArgs e) { Response.ClearContent(); Response.AddHead ...
- HDU 5375 Gray code(DP)
题意:给一串字符串,里面可能出现0,1,?,当中问号可能为0或1,将这个二进制转换为格雷码后,格雷码的每位有一个权值,当格雷码位取1时.加上该位权值,求最大权值和为多少. 分析:比赛的时候愚了.竟然以 ...
- Reuse Is About People and Education, Not Just Architecture
 Reuse Is About People and Education, Not Just Architecture Jeremy Meyer you MigHT AdopT THE AppRoA ...
- RvmTranslator6.4 is released
RvmTranslator6.4 is released eryar@163.com RvmTranslator can translate the RVM file exported by AVEV ...
- vim 基础学习之查找
普通模式下 /->正向查找 n-向下查找 N-向上查找 ?->反向查找 N-向下查找 n-向上查找 <C-r><C-w> <C-r>-引用,例如引用寄存 ...
- Python: PS 滤镜-- Fish lens
本文实现 PS 滤镜中的一种几何变换– Fish lens, 对图像做扭曲,感觉就像通过一个凸镜或者凹镜在观察图像一样. import numpy as np from skimage import ...
- Vue的响应原理
渲染render function之后就是 核心的响应式过程了 Object.defineProperty vue的核心之一就是Object.defineProperty 方法(IE9及其以上) Ob ...
- android webview 报 [ERROR:in_process_view_renderer.cc(189)] Failed to request GL process. Deadlock likely: 0 问题
工作中遇到 使用webview中加载含有audio标签的页面时提示[ERROR:in_process_view_renderer.cc(189)] Failed to request GL proce ...
- POJ 2185 正解 KMP
题意: 思路: 把每一行压成一个数 求一下 KMP 把每一列压成一个数 求一下KMP 答案就是两个周期之积 网上的好多题解都是错的---------.. //By SiriusRen #include ...
- VS中创建自定义一个VC工程为基础的开发向导的总结
作者:朱金灿 来源:http://blog.csdn.net/clever101 VS允许用户进行自定义开发向导.自定义开发向导的好处在于将常用的设置都通过向导生成,从而大大提供开发效率.特别是在开发 ...