Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when onEnd removed component tweening state #24

Closed
natew opened this issue Mar 2, 2015 · 3 comments
Closed

Error when onEnd removed component tweening state #24

natew opened this issue Mar 2, 2015 · 3 comments

Comments

@natew
Copy link

natew commented Mar 2, 2015

This should probably work:

      this.tweenState('step', {
        endValue: 2,
        duration: this.props.animationDuration,
        onEnd: this.props.onClose
      });

But if props.onClose removes the tweening element I get an error setState on non-mounted component. This fixes it for now:

      this.tweenState('step', {
        endValue: 2,
        duration: this.props.animationDuration,
        onEnd: () => {
          setTimeout(this.props.onClose);
        }
     });
@agido-freudenreich
Copy link

I've the same problem but setting a timeout did not fix it.

I use tweenState in combination with componentWillLeave.

The problem is in _rafCb():

if (!this.isMounted()) {
      return;
    }

At method call the component is still mounted but the state changed till setState() is called.
Quickfix: Add the same check just before setState().

@chenglou
Copy link
Owner

Thanks and sorry for the wait!

Fortunately with React 0.13, setting state after unmounting doesn't throw anymore. The warning's still bothersome though, so I'll make the change @agidoSF suggested. (@natew: your fix didn't work for me either).

@chenglou
Copy link
Owner

@agidoSF @natew I just released v0.0.5, which contains the fix, because this is the last release compatible with React < 0.13 (0.13 actually breaks something in tween-state and I'm fixing it now). Seemed better than to jump straight to supporting only React 0.13+ and leaving people at 0.12 without this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants