I'm getting this warning from react in the console:
Warning: bind(): You are binding a component method to the component. React does this for you automatically in a high-performance way, so you can safely remove this call. See Modal
Here is the call where's it happening (look for the arrow in comments on right side)
componentWillUnmount: function() {
if (this.props.ariaHideApp) {
ariaAppHider.show(this.props.appElement);
}
var state = this.portal.state;
var now = Date.now();
var closesAt = state.isOpen && this.props.closeTimeoutMS
&& (state.closesAt
|| now + this.props.closeTimeoutMS);
if (closesAt) {
if (!state.beforeClose) {
this.portal.closeWithTimeout();
}
setTimeout(this.removePortal.bind(this), closesAt - now); /// <-- This line
} else {
this.removePortal();
}
},
I think it happens when I unmount a modal when it's still disappearing.
I also got this warning when use with more than one modal on same page.
This can be due to some double bind(). Can you guys make a PR for this?
If changing this.removePortal.bind(this) to this.removePortal works, than it's a fix.
Tested, works fine, made pull request https://github.com/reactjs/react-modal/pull/348
[edit] actually, it need to be confirmed.
this inside of the callback of the setTimeout's function. see he's comment on the PR.yeah, I don't know how to fix then.
bind -> react gives warning
don't bind -> runs at wrong time, test fails
use es6 -> works w/o warning but uglify fails
yeah, this is kinda sad. this mixture of es5/6.
componentWillUnmount: function() {
var modal = this;
{...}
// yes, old style closure...
setTimeout(function() { console.log(this, modal); modal.removePortal(); }, 1);
}
I think that just having bind there is probably the best for now. The warning shouldn't cause problems. I mean the goal is that 1.7 is a release to appease people as an intermediate to 2.0. Backporting from a ES2015+ codebase to a ES5 codebase is messy.
@claydiffrient @diasbruno @mreishus I just submitted PR #353 which should solve this.
Since this issue has a fix, I'm closing this issue.
Thanks @mreishus and @adjohnson916 for taking care of this one.
thanks, sorry about the mess, I was just trying to make things easier~
Most helpful comment
Tested, works fine, made pull request https://github.com/reactjs/react-modal/pull/348