Skip to content

Commit

Permalink
Improving Modal visible prop check to handle undefined and null (#2…
Browse files Browse the repository at this point in the history
…2072)

Summary:
Changing the the this.props.visible if to be ` if (!!this.props.visible === false)` . So passing undefined, or other values wont set the modal to be visible. Granting that anything that is not true, will set the modal to null on the render.

I make this this PR, because on the company that im working, we used a lot of RN. At the moment, we arent using anything like flow or TS. But to grant that the modals will only show if they are set visible to true i have changed the if made.

_Pull requests that expand test coverage are more likely to get reviewed. Add a test case whenever possible!_
Pull Request resolved: #22072

Differential Revision: D12918086

Pulled By: TheSavior

fbshipit-source-id: 8f9c63ac6fd56d83949bb8428ad7c5b7bf805c49
  • Loading branch information
MateusAndrade authored and kelset committed Nov 26, 2018
1 parent d0c8cb1 commit 6c85356
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Libraries/Modal/Modal.js
Expand Up @@ -201,7 +201,7 @@ class Modal extends React.Component<Object> {
}

render(): React.Node {
if (this.props.visible === false) {
if (this.props.visible !== true) {
return null;
}

Expand Down

1 comment on commit 6c85356

@RoJoHub
Copy link
Contributor

@RoJoHub RoJoHub commented on 6c85356 Dec 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It happened that I encountered this problem and it happened to be solved. Haha

Please sign in to comment.