Skip to content

Commit

Permalink
🛠 Refactor: Rename ModalView.state.visible
Browse files Browse the repository at this point in the history
Summary: Rename `ModalView.state.visible` to `shouldMountModalContent`.
  • Loading branch information
dominicstop committed Jan 9, 2023
1 parent 7f0ab6d commit 55e72b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/components/ModalView/ModalView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class ModalView extends
this.emitter = new TSEventEmitter();

this.state = {
visible: false,
shouldMountModalContent: false,
childProps: null,
enableSwipeGesture: props.enableSwipeGesture,
isModalInPresentation: props.isModalInPresentation,
Expand All @@ -69,7 +69,7 @@ export class ModalView extends

componentWillUnmount() {
const { autoCloseOnUnmount } = this.getProps();
const { visible } = this.state;
const { shouldMountModalContent: visible } = this.state;

if (autoCloseOnUnmount && visible) {
this.setVisibility(false);
Expand Down Expand Up @@ -170,7 +170,7 @@ export class ModalView extends
};

setVisibility = async (nextVisible, childProps = null) => {
const { visible: prevVisible } = this.state;
const { shouldMountModalContent: prevVisible } = this.state;

const didChange = (prevVisible !== nextVisible);

Expand Down Expand Up @@ -299,7 +299,7 @@ export class ModalView extends
);

this.setState({
visible: false,
shouldMountModalContent: false,
childProps: null,
// reset state values from props
enableSwipeGesture: props.enableSwipeGesture,
Expand Down Expand Up @@ -366,7 +366,7 @@ export class ModalView extends
{...overrideProps}
{...props.viewProps}
>
{state.visible && (
{state.shouldMountModalContent && (
<View
style={[styles.modalContentContainer, props.containerStyle]}
collapsable={false}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ModalView/ModalViewTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export type ModalViewProps =
ViewProps & ModalViewBaseProps;

export type ModalViewState = {
visible: boolean;
shouldMountModalContent: boolean;
childProps: unknown;
enableSwipeGesture: boolean;
isModalInPresentation: boolean;
Expand Down

0 comments on commit 55e72b4

Please sign in to comment.