react-native-modalbox icon indicating copy to clipboard operation
react-native-modalbox copied to clipboard

`componentWillReceiveProps` does not reflect `isOpen` prop properly.

Open codebymikey opened this issue 7 years ago • 2 comments

The current componentWillReceiveProps function does not reflect the new properties accordingly.

If the isOpen property is modified, the handleOpenning function ends up comparing nextProps.isOpen against this.props.isDisabled in the open/close functions which shouldn't be the case.

It'd make more sense to pass in the current props and replace stuff like:

close: function() {
    if (this.props.isDisabled) return;
    if (!this.state.isAnimateClose && (this.state.isOpen || this.state.isAnimateOpen)) {
      delete this.onViewLayoutCalculated;
      this.animateClose();
    }
  }

with

close: function(nextProps = null) {
    let props = nextProps || this.props;
    if (props.isDisabled) return;
    if (!this.state.isAnimateClose && (this.state.isOpen || this.state.isAnimateOpen)) {
      delete this.onViewLayoutCalculated;
      this.animateClose();
    }
  }

Or better yet, just move the handleOpenning function into componentDidUpdate instead.

codebymikey avatar Apr 12 '17 13:04 codebymikey

any PR for this?

teyou avatar Jun 25 '17 07:06 teyou

++

77TecShaeer avatar Aug 28 '21 16:08 77TecShaeer