@@ -127,7 +127,6 @@ export class Toolbar extends React.Component<IToolbarProps, IToolbarState> {
127
127
super ( props ) ;
128
128
129
129
const repo = this . props . model . pathRepository ;
130
- this . _addListeners ( ) ;
131
130
132
131
this . state = {
133
132
branchMenu : false ,
@@ -137,10 +136,17 @@ export class Toolbar extends React.Component<IToolbarProps, IToolbarState> {
137
136
} ;
138
137
}
139
138
139
+ /**
140
+ * Callback invoked immediately after mounting a component (i.e., inserting into a tree).
141
+ */
142
+ componentDidMount ( ) : void {
143
+ this . _addListeners ( ) ;
144
+ }
145
+
140
146
/**
141
147
* Callback invoked when a component will no longer be mounted.
142
148
*/
143
- componentWillUnmount ( ) {
149
+ componentWillUnmount ( ) : void {
144
150
this . _removeListeners ( ) ;
145
151
}
146
152
@@ -280,9 +286,6 @@ export class Toolbar extends React.Component<IToolbarProps, IToolbarState> {
280
286
* Adds model listeners.
281
287
*/
282
288
private _addListeners ( ) : void {
283
- // When the repository changes, we're likely to have a new set of branches:
284
- this . props . model . repositoryChanged . connect ( this . _syncState , this ) ;
285
-
286
289
// When the HEAD changes, decent probability that we've switched branches:
287
290
this . props . model . headChanged . connect ( this . _syncState , this ) ;
288
291
@@ -294,7 +297,6 @@ export class Toolbar extends React.Component<IToolbarProps, IToolbarState> {
294
297
* Removes model listeners.
295
298
*/
296
299
private _removeListeners ( ) : void {
297
- this . props . model . repositoryChanged . disconnect ( this . _syncState , this ) ;
298
300
this . props . model . headChanged . disconnect ( this . _syncState , this ) ;
299
301
this . props . model . statusChanged . disconnect ( this . _syncState , this ) ;
300
302
}
0 commit comments