Skip to content

Commit 01363ef

Browse files
author
Vlad Balin
committed
Bug fixes
1 parent ecf2d31 commit 01363ef

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

react-nested.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* React-Backbone.Glue 0.1.0 <https://github.com/Volicon/react-backbone.glue>
2+
* React-Backbone.Glue 0.1.1 <https://github.com/Volicon/react-backbone.glue>
33
* (c) 2015 Vlad Balin & Volicon
44
* Released under MIT @license
55
*/
@@ -172,12 +172,7 @@
172172
// new element instance needs to be created on next render...
173173
if( this.element ){
174174
this.element = null;
175-
176-
if( this.component && this.component.trigger ){
177-
this.stopListening( this.component );
178-
}
179-
180-
this.component = null;
175+
this.unmountComponent();
181176
}
182177

183178
return Backbone.View.prototype.setElement.apply( this, arguments );
@@ -186,6 +181,17 @@
186181
// cached instance of react component...
187182
component : null,
188183

184+
unmountComponent : function(){
185+
if( this.component ){
186+
if( this.component.trigger ){
187+
this.stopListening( this.component );
188+
}
189+
190+
React.unmountComponentAtNode( this.el );
191+
this.component = null;
192+
}
193+
},
194+
189195
render : function(){
190196
if( !this.element ){
191197
this.element = React.createElement.apply( React, this._args );
@@ -199,6 +205,11 @@
199205
this.trigger.apply( this, arguments );
200206
});
201207
}
208+
},
209+
210+
dispose : function(){
211+
this.unmountComponent();
212+
Backbone.View.prototype.dispose.apply( this, arguments );
202213
}
203214
});
204215

0 commit comments

Comments
 (0)