• Stars
    star
    999
  • Rank 45,787 (Top 1.0 %)
  • Language
  • Created over 9 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Make your React app work in IE8

中文 README

Make your React app work in IE8

It's really a dispiriting news that Starting with React v15, we're discontinuing React DOM's support for IE 8. There are still more than 18% people who are using IE8 in China.

Anyway, react-ie8 will continuously provide a series of Examples for people who are facing the same compatible problems, as well as collecting issues.

Have fun with react-ie8 Examples, and feel free to Open an issue.

How to

First you shouldn't use React v15 or higher version anymore. Just use React v0.14 which still support IE8.

If you need docs for React v0.14, go to http://react-ie8.xcatliu.com

Using CommonJS

I highly recommend to use CommonJS style to include required packages.

First install these packages:

npm install --save es5-shim console-polyfill

Then insert the code into the beginning of your entry file:

require('es5-shim');
require('es5-shim/es5-sham');
require('console-polyfill');

See React IE8 Hello World Example for a real example.

React Static Boilerplate

React Static Boilerplate A React static boilerplate that supports IE8,To view Demo

Other Problems

Some problems are actually not the problem of React, but I also list them below:

Error Message Reason Solution Related Issue Example
Expected identifier Reserved words such as default are used in your code or in third party packages Use es3ify or es3ify-loader to transform your code #1 Fetch IE8
Exception thrown and not caught Babel transforms your export * from 'xxx' to Object.defineProperty which doesn't support accessor property in IE8 Insert require('es5-shim') require('es5-shim/es5-sham') in the top of your entry file, and DONOT use export * from 'xxx' in your code #2 #32 Hello World
Object expected Perhaps you are using fetch without polyfilled Use es6-promise and fetch-ie8 to polyfill fetch #4 Fetch IE8
'Promise' is undefined Promise need to be polyfilled in IE8 Use es6-promise to polyfill Promise #5 Fetch IE8
Object doesn't support this property or method Perhaps you are using Object.assign Use core-js to polyfill #7 Object Assign
'JSON' is undefined Need to use IE8 Standards Mode Add <!DOCTYPE html> and <meta http-equiv="X-UA-Compatible" content="IE=EDGE"/> #8 Hello World

If you have other problems, please Open an issue.

Troubleshooting

Troubleshooting in issues

Reference

使你的 React 应用兼容 IE8

一个令人失望的消息:从 React v15 开始,React DOM 将不会再支持 IE8 了。而中国还有超过 18% 的人在使用 IE8

无论如何,react-ie8 仍会提供一系列的示例,还会收集 issues,以便于给遇到兼容性问题的人一个参考。

快去查看 react-ie8 示例吧,也欢迎提交 issue

如何兼容 IE8

首先,你不应该使用 React v15 或更高版本。使用仍然支持 IE8 的 React v0.14 即可。

如果你需要查看 React v0.14 的文档,请访问:http://react-ie8.xcatliu.com

使用 CommonJS

强烈推荐使用 CommonJS 风格来引入需要的模块。

首先安装这些模块:

npm install --save es5-shim console-polyfill

然后把以下代码插入到入口文件最前面

require('es5-shim');
require('es5-shim/es5-sham');
require('console-polyfill');

参考一个真实的例子:React IE8 Hello World Example

使用 React Static Boilerplate

React Static Boilerplate 一个创建好的支持 IE8 的 React 静态模板,可以查看演示

其他问题

一些问题其实并不是 React 的问题,不过我也把他们列出来了:

错误信息 原因 解决方案 相关 Issue 示例
Expected identifier 代码中或者第三方模块中使用了保留字,比如 default 使用 es3ify 或者 es3ify-loader #1 Fetch IE8
Exception thrown and not caught babel 把 export * from 'xxx' 编译成了 Object.defineProperty,而 IE8 中不支持 accessor property require('es5-shim') require('es5-shim/es5-sham') 插入到入口文件的最上方,并且在代码中不要使用 export * from 'xxx' #2 #32 Hello World
Object expected 可能你使用了 fetch es6-promisefetch-ie8 polyfill #4 Fetch IE8
'Promise' is undefined Promise 需要 polyfill es6-promise polyfill #5 Fetch IE8
Object doesn't support this property or method 可能你使用了 Object.assign core-js polyfill #7 Object Assign
'JSON' is undefined 需要使用 IE8 Standards Mode 添加 <!DOCTYPE html><meta http-equiv="X-UA-Compatible" content="IE=EDGE"/> #8 Hello World

如果你遇到了其他问题,可以提交一个 issue

Troubleshooting

Troubleshooting in issues

参考

More Repositories

1

typescript-tutorial

TypeScript 入门教程
TypeScript
10,357
star
2

pagic

A static site generator powered by Deno + React
JavaScript
1,637
star
3

chatgpt-next

微信风格的 ChatGPT,使用 Next.js 构建,私有化部署的最佳选择!
TypeScript
761
star
4

jekyllcn

Jekyll 的中文翻译网站
Ruby
470
star
5

cqc

Code Quality Checker - Check your code quality by running one command.
JavaScript
323
star
6

leetcode

My LeetCode Solutions
JavaScript
315
star
7

mazimd

码字 md • 干净精致的 Markdown 编辑器
JavaScript
120
star
8

123

The personal front page
CSS
72
star
9

blog

流浪小猫的博客
TypeScript
72
star
10

awesome-json2json

An awesome json to json data mapper
JavaScript
67
star
11

V2HOT

V2HOT is an iOS App made by @xcatliu, powered by React Native.
JavaScript
55
star
12

xcatliu

About me
TypeScript
54
star
13

react-select-pinyin

React 选择控件(支持拼音搜索)
JavaScript
31
star
14

buy-me-a-coffee

☕ Buy me a coffee
29
star
15

awesome-aigc

29
star
16

hexo-theme-wiki-i18n

A hexo theme for i18n wiki site
HTML
28
star
17

xzoo

可爱的动物头像,为你设计。 Lovely animal avatars, designed for you.
26
star
18

js-index

🔠 The index of everything about JavaScript
HTML
24
star
19

simplemde-theme-base

The base theme for SimpleMDE, you can easily build your custom theme based on this.
CSS
22
star
20

full-color-screen

Display a solid color across the entire display.
22
star
21

hexo-filter-date-from-git

Read git log and overwrite the front-matter properties `date` and `updated` for each posts
JavaScript
13
star
22

goodbye-ie8

Goodbye IE8
HTML
13
star
23

simplemde-theme-dark

The dark theme of SimpleMDE
CSS
12
star
24

pagic_template_docs

Use this template to create a Pagic site with the docs theme
TypeScript
12
star
25

etype

Extra types for TypeScript
JavaScript
11
star
26

grubbs

Online Grubbs' test for outliers
JavaScript
11
star
27

add-eslint-comment

Add ESLint comment per file according to the ESLint result.
JavaScript
9
star
28

mangastream

A wordpress theme for mangastream
PHP
7
star
29

spells

360 Spells of 360 Colors
JavaScript
7
star
30

react-errors

Show errors on the top-right
JavaScript
6
star
31

the-war-of-colors

JavaScript
6
star
32

ts-react

TypeScript React Boilerplate
TypeScript
6
star
33

hexo-generator-index-i18n

I18n index generator plugin for Hexo
JavaScript
5
star
34

insert-tag

Insert tag to the specific position of a html string
TypeScript
5
star
35

Thinking-in-React

An implement for Thinking in React
JavaScript
5
star
36

the-secret-of-maintaining-100000-lines-of-javascript-code

维护十万行 JavaScript 代码的秘诀
5
star
37

rose

Give your love a rose
HTML
4
star
38

light-stick

拍一个创意炫彩照,俘获妹子芳心
CSS
4
star
39

mazimd-api

The api server for mazimd
JavaScript
3
star
40

geocn

中国最完整最精确的行政区划数据与应用平台
2
star
41

smart-serialize

Serialize any object, stringify, print to console, and write to clipboard
JavaScript
2
star
42

hexo-filter-author-from-git

Read git log and add the properties `author` and `contributors` for each posts
JavaScript
2
star
43

typescript-travis-ci

JavaScript
2
star
44

fe-dotfiles

dotfiles for my front-end projects
JavaScript
2
star
45

codeeval

My codeeval solutions
JavaScript
2
star
46

removethem

RemoveThem 一款有趣的Web游戏
JavaScript
1
star
47

github2p

Generate any github repo to web pages in one second.
1
star
48

learning-react

The way I learning react.
JavaScript
1
star
49

rematch-typescript

1
star
50

react-gmap

Google Maps component for React
JavaScript
1
star
51

xcombo

A NodeJS combo server
1
star
52

xcatblog

Xcatblog is a blog system, isomorphic application, the React way.
JavaScript
1
star
53

C

Learning C
1
star
54

react-boilerplate

1
star
55

v2hot.trash

JavaScript
1
star
56

xduck

JavaScript
1
star
57

timeout

1
star
58

require-uncache

Remove all cached files associated with the module.
JavaScript
1
star
59

LICENSES

1
star
60

react-input-file

An `<input type="file"/>` implement which support dragging files from desktop
1
star
61

hexo-theme-xcatliu

CSS
1
star
62

xImage

A html5 canvas image editor.
1
star
63

Todo-Hodgepodge

Todo Apps collections wrote with different program languages and different database systems.
1
star
64

react-github-buttons

1
star
65

xtree

A skill tree system.
JavaScript
1
star
66

react-select2

1
star
67

react-webpack-redux-react-router

1
star
68

fepost

JavaScript
1
star
69

6rainbow

TypeScript
1
star