-
Notifications
You must be signed in to change notification settings - Fork 47.4k
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
Event still processing after component unmounted #2605
Comments
Can you provide a simplified test case demonstrating the issue? Thanks. |
Tried but not able to reproduce that problem in a small one, while it still can be reproduced in our app(sorry I can't show the code). Code in my attempt was(and it doesn't give exceptions): React = require 'react'
AppClosing = require './app/closing'
view =
el: document.body
addComponent: ->
component = AppClosing onCloseClick: =>
@unmountComponent()
React.render component, @el
unmountComponent: ->
React.unmountComponentAtNode @el
view.addComponent()
React = require 'react'
$ = React.DOM
module.exports = React.createFactory React.createClass
displayName: 'app-closing'
propTypes:
onCloseClick: React.PropTypes.func.isRequired
onCloseClick: ->
@props.onCloseClick()
render: ->
$.div className: 'app-closing',
$.p className: 'about', 'Open console to see the exception.'
$.div className: 'button', onClick: @onCloseClick, 'Close' Some differences in my real app is that app is writtern mixed with Backbone View and React Component , Component inside VIew. |
Based on that error you are loading 2 Reacts |
@browniefed In my app there are more than 5 components mounted to Backbone Views if you mean React components. Why is that a problem? |
I'm having the same error but if i call React.unmountComponentAtNode(document.getElementById('modals-container')); and the next action is React.render( 'anothermodal' ); everything is ok... without this React.render im getting that error... its like React is dispatching an event to clean everything after unmount the component and he can't find it of course |
So after a long time ignoring this error i found why... i was trying to unmount the component when react trigger an event... so react don't support that because they have a crazy event dispatcher behind.. so my solution for now is
so the unmount will be trigger on the next browser tick. |
I'm seeing this being logged sometimes as well. If it is helpful, here's the stack trace with a little context:
|
Here's a seemingly similar stack trace I also noticed:
|
@jiyinyiyong What @browniefed meant is two copies of React, as discussed/described in: https://gist.github.com/jimfb/4faa6cbfb1ef476bd105 I'm not sure if that's actually the problem, but it's worth checking. |
@lencioni Since you're just jumping in on this thread now (months later) with a stack trace, I'm assuming your stack trace does not correspond to the code above, right? It looks to me like this bug does not have a clear repro. Based on @gsantome's response, it looks like he was running into #3298 I'm going to close this issue. We can reopen if this is incorrect. Or open a new issue if we can get a consistent repro that indicates a bug in React. |
That's correct. I arrived here via searching and posted my stack traces just in case they were helpful. |
Suppose a Backbone View named A, which contains a React component B. In B(React) there's a button, clicking the button unnmounts B(React) and rerenders A(Backbone). In my case I got an error like:
After looking into it, I found events still processing even after that component unmounted from DOM. By examining
processingEventQueue
I found that event is that click event to do all this.For now I added
setTimeout
(100ms) in my click handler and it became ok.Is there any plan to fix this case and React will just work with a timeout?
The text was updated successfully, but these errors were encountered: