A proper modal window resets itself upon closing.
It can be reset immediately when isOpen is set to false but that introduces glitches due to resetting and repainting the modal window before closing animation is played.
An onAfterClose handler run in componentWillUnmount would resolve this issue.
I can make a PR if you are willing to accept this feature.
This would be awesome.
While this prop would be very helpful, my case was simple enough to implement it manually:
onRequestClose = () => {
this.props.closeModal()
setTimeout(
this.props.resetModal,
this.props.closeTimeoutMS
)
}
@megapctr no, this won't work, because there's absolutely no guarantee that by that time the modal component has been unmounted.
@megapctr And also this workaround won't work for programmatically closing the modal since it will either have to call this.refs.modal.close() (which is non-React way) or have to be upgraded to duplicate ModalPortal functionality:
componentWillReceiveProps: function(newProps) {
if (this.props.isOpen && !newProps.isOpen) {
setTimeout(
this.props.resetModal,
this.props.closeTimeoutMS
)
}
},
I found another way: simply componentWillUnmount() in the modal contents component