I'm having an issue with lodash in react. I've got the following code at the beginning of my render function. I get the value of layout from this.state & then on each layout object in the array, I set static as the inverse of the boolean property isEdit. However, I've tried everything and for some reason, I cannot access isEdit within my lodash function. It's undefined... I cannot figure out what I'm doing wrong, so any help would be appreciated.
public render() {
const { isEdit, size } = this.props;
const layout = this.state.layout.slice();
_.forEach(layout, (x) => {
x.static = !isEdit;
});
.....
Do you mean, all static property on layout are set to be true ? B'cos
!undefined would be true
.
Also can you set defaultProp for your isEdit prop, just to be sure.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.