Skip to content

Commit 805214e

Browse files
authored
chore(compass-home): add deps to avoid extra listener refreshes (#2575)
1 parent 8be6e79 commit 805214e

File tree

1 file changed

+4
-4
lines changed
  • packages/compass-home/src/components

1 file changed

+4
-4
lines changed

packages/compass-home/src/components/home.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { css } from '@emotion/css';
2-
import React, { useEffect, useReducer } from 'react';
2+
import React, { useCallback, useEffect, useReducer } from 'react';
33
import {
44
DataService,
55
getConnectionTitle,
@@ -200,7 +200,7 @@ function Home({ appName }: { appName: string }): React.ReactElement | null {
200200
});
201201
}
202202

203-
function onDataServiceDisconnected() {
203+
const onDataServiceDisconnected = useCallback(() => {
204204
const StatusAction = appRegistry.getAction(
205205
AppRegistryActions.STATUS_ACTIONS
206206
) as StatusActionType | undefined;
@@ -209,7 +209,7 @@ function Home({ appName }: { appName: string }): React.ReactElement | null {
209209
});
210210
updateTitle(appName);
211211
StatusAction?.done();
212-
}
212+
}, [appRegistry, appName]);
213213

214214
useEffect(() => {
215215
if (isConnected) {
@@ -248,7 +248,7 @@ function Home({ appName }: { appName: string }): React.ReactElement | null {
248248
);
249249
appRegistry.removeListener('all-collection-tabs-closed', onAllTabsClosed);
250250
};
251-
});
251+
}, [appRegistry, onDataServiceDisconnected]);
252252

253253
if (isConnected) {
254254
return (

0 commit comments

Comments
 (0)