Open ariesshrimp opened 8 years ago
This is resolved. Added a default object catch into the Object.assign
list to override any unwanted undefined
s with the right default attributes.
This is worse than I thought. Object.assign doesn't deep check nested data structures. For example:
const original = {
prop1: {
prop2: true
}
}
const new = {
prop1: {
prop3: 'OIJOJSDOFJOIJF'
}
}
const updated = Object.assign({}, original, new)
updated.prop1.prop2 // undefined, because new.prop1 doesn't have one.
Currently
<ForecastDisplay>
uses Object.assign in its componentDidMount updates. Unfortunately,Object.assign
keeps falsy andundefined
values from its incoming objects. That means that sensible backups are still needed internally in the render method to avoid showing "undefined" values.