[fix] JS error after delete row level tab (#6393)

This commit is contained in:
Grace Guo 2018-11-15 10:30:08 -08:00 committed by GitHub
parent e66b0469b4
commit ec1316a5a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 9 deletions

View File

@ -39,15 +39,17 @@ function mapStateToProps(
// rows and columns need more data about their child dimensions
// doing this allows us to not pass the entire component lookup to all Components
const componentType = component.type;
if (componentType === ROW_TYPE || componentType === COLUMN_TYPE) {
const { occupiedWidth, minimumWidth } = getDetailedComponentWidth({
id,
components: dashboardLayout,
});
if (component) {
const componentType = component.type;
if (componentType === ROW_TYPE || componentType === COLUMN_TYPE) {
const { occupiedWidth, minimumWidth } = getDetailedComponentWidth({
id,
components: dashboardLayout,
});
if (componentType === ROW_TYPE) props.occupiedColumnCount = occupiedWidth;
if (componentType === COLUMN_TYPE) props.minColumnWidth = minimumWidth;
if (componentType === ROW_TYPE) props.occupiedColumnCount = occupiedWidth;
if (componentType === COLUMN_TYPE) props.minColumnWidth = minimumWidth;
}
}
return props;
@ -68,7 +70,7 @@ function mapDispatchToProps(dispatch) {
class DashboardComponent extends React.PureComponent {
render() {
const { component } = this.props;
const Component = ComponentLookup[component.type];
const Component = component ? ComponentLookup[component.type] : null;
return Component ? <Component {...this.props} /> : null;
}
}