LoginSignup
4
12

More than 5 years have passed since last update.

Reactレガシーブラウザ対応

Posted at

Reactでコードを書くにあたり、モバイルのレガシーブラウザ対応に関する調査内容を記す。
なお、React経験1ヶ月もないので有識者ではない。

古い端末対応

i0S6, 7, android4系端末対応のため下記導入

npm install --save-dev es5-shim es6-shim babel-preset-es2015-loose

.babelrcにes2015-loose追記

{
  "presets": ["es2015-loose", "es2015", "react"]
}

Promise

adnroid4系でPromise動かないからpolyfillいれる。
promiseがうごかないので下記の取得系のパッケージでバグる。ハマル。

パッケージ導入

下記をインストール

npm install --save es6-promise

インストール後、これをルートのjsxに入れればandroid4系の標準ブラウザでpromiseが動く。

src/index.jsx
import 'es6-promise/auto';

詳細はここを参照
stefanpenner/es6-promise: A polyfill for ES6-style Promises

メモ

babelに下記を食わして、コードに影響を与えず対応したかったが、どうもまくいかなかった。

babel-plugin-es6-promise https://www.npmjs.com/package/babel-plugin-es6-promise

参考

4
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
12