[英]Lodash & React, Unable to access local variables
我在lodash的反应中遇到问题。 我的渲染函数的开头有以下代码。 我从this.state获得layout的值,然后在数组中的每个布局对象上,将static设置为boolean属性isEdit的反函数。 但是,我已经尝试了一切,由于某种原因,我无法在lodash函数中访问isEdit。 这是未定义的...我无法弄清楚自己在做什么错,因此我们将不胜感激。
public render() {
const { isEdit, size } = this.props;
const layout = this.state.layout.slice();
_.forEach(layout, (x) => {
x.static = !isEdit;
});
.....
您是说将布局上的所有静态属性都设置为true 吗? B'cos
!undefined would be true
。
可以肯定的是,您也可以为isEdit prop设置defaultProp 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.