Reactjs 将类与webpack2和react进行比较
在升级到webpack 2之前,我可以执行以下操作:Reactjs 将类与webpack2和react进行比较,reactjs,webpack,webpack-2,Reactjs,Webpack,Webpack 2,在升级到webpack 2之前,我可以执行以下操作: children: PropTypes.arrayOf((propValue, key) => { const type = propValue[key].type if (type !== Column && type !== ColumnGroup) { throw new Error('<Table> can only have <Column>
children: PropTypes.arrayOf((propValue, key) => {
const type = propValue[key].type
if (type !== Column && type !== ColumnGroup) {
throw new Error('<Table> can only have <Column> and <ColumnGroup> as children.')
}
})
更新:
它与将NODE_ENV设置为与production不同的值有关。我可以在这里重现这一点:显然,这是由react热加载程序引起的已知问题 我通过在组件类上添加自己的静态变量并进行比较来解决这个问题
children: PropTypes.arrayOf((propValue, key) => {
const {_componentClass} = propValue[key].type
if (_componentClass !== Column._componentClass && _componentClass !== ColumnGroup._componentClass) {
throw new Error('<Table> can only have <Column> and <ColumnGroup> as children.')
}
})
children:PropTypes.arrayOf((propValue,key)=>{
常量{u componentClass}=propValue[key]。类型
如果(_componentClass!==列._componentClass&&&u componentClass!==列组._componentClass){
抛出新错误('只能将和作为子项')
}
})
不太理想,但它可以工作。您使用的是某种迷你型吗?不。不过我使用的是CommonsChunk插件。也许这与此有关?我不这么认为。您使用的是哪个版本的React?我为React和React dom提供了“^15.3.1”,并对npm缓存进行了清理和安装,因此无论最新版本是什么。我已经接近了解它了。如果在构建时没有显式设置节点_ENV,那么问题就会消失。不过,我不太确定接下来该怎么办。
children: PropTypes.arrayOf((propValue, key) => {
const {_componentClass} = propValue[key].type
if (_componentClass !== Column._componentClass && _componentClass !== ColumnGroup._componentClass) {
throw new Error('<Table> can only have <Column> and <ColumnGroup> as children.')
}
})