不可变记录getIn在ie10中失败
immutable record getIn fails in ie10
这里是不可变记录class定义
import Immutable, {Record} from 'immutable';
const FEATURE_DEFAULTS = {
name: null,
};
export class Feature extends Record(FEATURE_DEFAULTS) {
}
一个实例是这样初始化的:
const featureName = 'a value';
const b = new Feature({ name: featureName });
console.log(b.getIn(['name']));
在大多数现代浏览器(chrome、safari 等)中,它都有效。它按预期打印出 name
字段中的值。
但是在ie10中,b.getIn(['name'])
抛出这个异常:Unable to get property 'hasOwnProperty' of undefined or null reference
关于我的项目的更多信息,它使用这些依赖项
"immutable": "^3.8.1",
"react": "^15.1.0",
"react-chartist": "^0.10.1",
"react-dom": "^15.1.0",
"react-intl": "2.1.2",
"react-redux": "^4.4.5",
"react-router": "^2.4.1",
"redux": "^3.5.2",
"redux-thunk": "^2.1.0",
"reselect": "^2.5.1",
我也在用babel
翻译es6语法
"babel-core": "^6.9.1",
"babel-eslint": "^6.0.4",
"babel-loader": "^6.2.4",
"babel-polyfill": "^6.9.1",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"babel-register": "^6.9.0",
"babel-runtime": "^6.9.2",
我该如何解决这个问题?
编辑:
我认为异常是从这里抛出的:
https://github.com/facebook/immutable-js/blob/38019326a8d006a45ef48d9c4644e23ea476d298/src/Record.js#L55
我从 babel 的错误跟踪器中找到了解决方案 https://phabricator.babeljs.io/T3041
基本上步骤是:
npm 安装 babel-plugin-transform-class-properties
npm 安装 babel-plugin-transform-es2015-classe
将这些插件添加到 .babelrc
:
"plugins": [
"transform-class-properties",
['transform-es2015-classes', {loose: true}]
]
这里是不可变记录class定义
import Immutable, {Record} from 'immutable';
const FEATURE_DEFAULTS = {
name: null,
};
export class Feature extends Record(FEATURE_DEFAULTS) {
}
一个实例是这样初始化的:
const featureName = 'a value';
const b = new Feature({ name: featureName });
console.log(b.getIn(['name']));
在大多数现代浏览器(chrome、safari 等)中,它都有效。它按预期打印出 name
字段中的值。
但是在ie10中,b.getIn(['name'])
抛出这个异常:Unable to get property 'hasOwnProperty' of undefined or null reference
关于我的项目的更多信息,它使用这些依赖项
"immutable": "^3.8.1",
"react": "^15.1.0",
"react-chartist": "^0.10.1",
"react-dom": "^15.1.0",
"react-intl": "2.1.2",
"react-redux": "^4.4.5",
"react-router": "^2.4.1",
"redux": "^3.5.2",
"redux-thunk": "^2.1.0",
"reselect": "^2.5.1",
我也在用babel
翻译es6语法
"babel-core": "^6.9.1",
"babel-eslint": "^6.0.4",
"babel-loader": "^6.2.4",
"babel-polyfill": "^6.9.1",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"babel-register": "^6.9.0",
"babel-runtime": "^6.9.2",
我该如何解决这个问题?
编辑:
我认为异常是从这里抛出的:
https://github.com/facebook/immutable-js/blob/38019326a8d006a45ef48d9c4644e23ea476d298/src/Record.js#L55
我从 babel 的错误跟踪器中找到了解决方案 https://phabricator.babeljs.io/T3041
基本上步骤是:
npm 安装 babel-plugin-transform-class-properties
npm 安装 babel-plugin-transform-es2015-classe
将这些插件添加到
.babelrc
:"plugins": [ "transform-class-properties", ['transform-es2015-classes', {loose: true}] ]