Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

componentWillUnmount is not getting invoked

I have a backbone application, where i am trying to integrate React components.

React component is mounted using following code : ReactDOM.render( <WrappedComponent />, node ); where node is the DOM mode. This way React lifecycle events like componentWillMount and componentDidMount are getting called fine.

But when routing happen through Backbone routing, and React component getting removed from DOM, componentWillUnmount is not invoked.

Any solutions ?

like image 354
Abhijeet Mishra Avatar asked Jan 09 '16 08:01

Abhijeet Mishra


1 Answers

componentWillUnmount does not get called automatically when the container node gets removed. It only gets called:

  1. At the top level, when you call ReactDOM.unmountComponentAtNode
  2. As child components, when the parent unmounts the component
like image 58
Michelle Tilley Avatar answered Oct 06 '22 01:10

Michelle Tilley