Skip to content

Commit

Permalink
fix(components): modal - state update during render
Browse files Browse the repository at this point in the history
  • Loading branch information
artyorsh authored Feb 6, 2020
1 parent b095d9f commit 39632ea
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/components/ui/modal/modal.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,25 @@ export class Modal extends React.PureComponent<ModalProps, State> {
this.modalId = ModalService.hide(this.modalId);
};

public componentDidMount(): void {
if (!this.modalId && this.props.visible) {
this.show();
return;
}
}

public componentDidUpdate(prevProps: ModalProps): void {
if (!this.modalId && this.props.visible && !this.state.forceMeasure) {
this.setState({ forceMeasure: true });
return;
}

if (!this.modalId && this.props.visible) {
this.show();
return;
}

if (this.modalId && !this.props.visible) {
// this.contentPosition = POINT_OUTSCREEN;
this.hide();
}
}
Expand Down Expand Up @@ -136,14 +147,8 @@ export class Modal extends React.PureComponent<ModalProps, State> {
};

public render(): React.ReactNode {
if (!this.modalId && this.props.visible) {
this.show();
return null;
}

if (this.modalId && this.props.visible) {
ModalService.update(this.modalId, this.renderContentElement());
return null;
}

return null;
Expand Down

0 comments on commit 39632ea

Please sign in to comment.