Merge pull request #38 from sdemjanenko/settimeout_check_mounted

Check isMounted in setTimeout
This commit is contained in:
Christian Alfoni 2015-03-07 09:51:05 +01:00
commit d04bae94f9
1 changed files with 2 additions and 0 deletions

View File

@ -151,6 +151,7 @@ Formsy.Mixin = {
if (!this.props._attachToForm) {
return setTimeout(function () {
if (!this.isMounted()) return;
if (!this.props._attachToForm) {
throw new Error('Form Mixin requires component to be nested in a Form');
}
@ -271,6 +272,7 @@ Formsy.Form = React.createClass({
// The updated children array is not available here for some reason,
// we need to wait for next event loop
setTimeout(function () {
if (!this.isMounted()) return;
this.registerInputs(this.props.children);
var newInputKeys = Object.keys(this.inputs);