@@ -106,7 +106,6 @@ export class NewBranchDialog extends React.Component<
106
106
super ( props ) ;
107
107
108
108
const repo = this . props . model . pathRepository ;
109
- this . _addListeners ( ) ;
110
109
111
110
this . state = {
112
111
name : '' ,
@@ -117,6 +116,13 @@ export class NewBranchDialog extends React.Component<
117
116
} ;
118
117
}
119
118
119
+ /**
120
+ * Callback invoked immediately after mounting a component (i.e., inserting into a tree).
121
+ */
122
+ componentDidMount ( ) : void {
123
+ this . _addListeners ( ) ;
124
+ }
125
+
120
126
/**
121
127
* Callback invoked when a component will no longer be mounted.
122
128
*/
@@ -281,9 +287,6 @@ export class NewBranchDialog extends React.Component<
281
287
* Adds model listeners.
282
288
*/
283
289
private _addListeners ( ) : void {
284
- // When the repository changes, we're likely to have a new set of branches:
285
- this . props . model . repositoryChanged . connect ( this . _syncState , this ) ;
286
-
287
290
// When the HEAD changes, decent probability that we've switched branches:
288
291
this . props . model . headChanged . connect ( this . _syncState , this ) ;
289
292
@@ -295,7 +298,6 @@ export class NewBranchDialog extends React.Component<
295
298
* Removes model listeners.
296
299
*/
297
300
private _removeListeners ( ) : void {
298
- this . props . model . repositoryChanged . disconnect ( this . _syncState , this ) ;
299
301
this . props . model . headChanged . disconnect ( this . _syncState , this ) ;
300
302
this . props . model . statusChanged . disconnect ( this . _syncState , this ) ;
301
303
}
0 commit comments