无法在 IE9/10 中获取 属性 ReactJS 的值
Unable to get value of the property ReactJS in IE9/10
我有一个反应组件,我正在使用以下代码渲染到 DOM 中:
ReactDOM.render(React.createElement(PROJECT.CalendarApp,
{ key : 'globalcalendar',
roomPage : false,
localeRegion : PROJECT.user.locale().region,
localeStartDay : PROJECT.user.locale().startDay,
showCalendarOnLoad : false,
name : 'globalcalendar',
availabilityCalendar : false
}),
document.getElementById('global_calendar_component'));
我在 IE 9/10 中收到以下错误,似乎无法找出原因 - Unable to get value of the property 'localeRegion' object is null or undefined reactjs
。
PROJECT.user.locale().region
定义正确,returns一串'en'
。
此问题仅出现在 IE 9 和 10 中,目前我的 webpack 设置如下所示:
var webpack = require('webpack');
var path = require('path');
var BUILD_DIR = path.resolve(__dirname, '../src/Family/SystemBundle/Resources/public/js/components/compiled');
var APP_DIR = path.resolve(__dirname, '../src/Family/SystemBundle/Resources/public/js/components/');
var config = {
entry: {
calendar : APP_DIR + '/calendar.jsx'
},
output: {
path: BUILD_DIR,
filename: '[name].js'
},
module : {
loaders : [
{
test : /\.jsx?/,
include : APP_DIR,
loader : 'babel',
query:
{
presets:[require.resolve('babel-preset-es2015'), require.resolve('babel-preset-react')] // Brackets - required for babel symlinking because node_modules is not in the root folder.
}
}
]
}
};
module.exports = config;
我已经将 Babel Polyfill 加载到项目中,我对这个问题感到很困惑。如果有人遇到过类似的事情,那么很高兴知道您是如何设法解决它的。
我们终于找到了这个问题的答案。问题是 IE9 不喜欢在 React 组件的构造函数中使用 props,但会允许在其他组件方法中使用 props。
要解决此问题,只需不要在构造函数中使用任何道具或尝试在 webpack 文件中使用 plugins: [['transform-es2015-classes', {loose: true}]]
。
此处有更多详细信息:https://phabricator.babeljs.io/T3041 & https://phabricator.babeljs.io/T6954
我有一个反应组件,我正在使用以下代码渲染到 DOM 中:
ReactDOM.render(React.createElement(PROJECT.CalendarApp,
{ key : 'globalcalendar',
roomPage : false,
localeRegion : PROJECT.user.locale().region,
localeStartDay : PROJECT.user.locale().startDay,
showCalendarOnLoad : false,
name : 'globalcalendar',
availabilityCalendar : false
}),
document.getElementById('global_calendar_component'));
我在 IE 9/10 中收到以下错误,似乎无法找出原因 - Unable to get value of the property 'localeRegion' object is null or undefined reactjs
。
PROJECT.user.locale().region
定义正确,returns一串'en'
。
此问题仅出现在 IE 9 和 10 中,目前我的 webpack 设置如下所示:
var webpack = require('webpack');
var path = require('path');
var BUILD_DIR = path.resolve(__dirname, '../src/Family/SystemBundle/Resources/public/js/components/compiled');
var APP_DIR = path.resolve(__dirname, '../src/Family/SystemBundle/Resources/public/js/components/');
var config = {
entry: {
calendar : APP_DIR + '/calendar.jsx'
},
output: {
path: BUILD_DIR,
filename: '[name].js'
},
module : {
loaders : [
{
test : /\.jsx?/,
include : APP_DIR,
loader : 'babel',
query:
{
presets:[require.resolve('babel-preset-es2015'), require.resolve('babel-preset-react')] // Brackets - required for babel symlinking because node_modules is not in the root folder.
}
}
]
}
};
module.exports = config;
我已经将 Babel Polyfill 加载到项目中,我对这个问题感到很困惑。如果有人遇到过类似的事情,那么很高兴知道您是如何设法解决它的。
我们终于找到了这个问题的答案。问题是 IE9 不喜欢在 React 组件的构造函数中使用 props,但会允许在其他组件方法中使用 props。
要解决此问题,只需不要在构造函数中使用任何道具或尝试在 webpack 文件中使用 plugins: [['transform-es2015-classes', {loose: true}]]
。
此处有更多详细信息:https://phabricator.babeljs.io/T3041 & https://phabricator.babeljs.io/T6954