@@ -106,7 +106,6 @@ export class NewBranchDialog extends React.Component<
106106 super ( props ) ;
107107
108108 const repo = this . props . model . pathRepository ;
109- this . _addListeners ( ) ;
110109
111110 this . state = {
112111 name : '' ,
@@ -117,6 +116,13 @@ export class NewBranchDialog extends React.Component<
117116 } ;
118117 }
119118
119+ /**
120+ * Callback invoked immediately after mounting a component (i.e., inserting into a tree).
121+ */
122+ componentDidMount ( ) : void {
123+ this . _addListeners ( ) ;
124+ }
125+
120126 /**
121127 * Callback invoked when a component will no longer be mounted.
122128 */
@@ -281,9 +287,6 @@ export class NewBranchDialog extends React.Component<
281287 * Adds model listeners.
282288 */
283289 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-
287290 // When the HEAD changes, decent probability that we've switched branches:
288291 this . props . model . headChanged . connect ( this . _syncState , this ) ;
289292
@@ -295,7 +298,6 @@ export class NewBranchDialog extends React.Component<
295298 * Removes model listeners.
296299 */
297300 private _removeListeners ( ) : void {
298- this . props . model . repositoryChanged . disconnect ( this . _syncState , this ) ;
299301 this . props . model . headChanged . disconnect ( this . _syncState , this ) ;
300302 this . props . model . statusChanged . disconnect ( this . _syncState , this ) ;
301303 }
0 commit comments