Skip to content

Commit c19246c

Browse files
committed
Use useStatus().
1 parent 75e673d commit c19246c

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

demos/diagnostics-app/src/app/views/layout.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ import React from 'react';
2828
import { LOGIN_ROUTE, SCHEMA_ROUTE, SQL_CONSOLE_ROUTE, SYNC_DIAGNOSTICS_ROUTE } from '@/app/router';
2929
import { useNavigationPanel } from '@/components/navigation/NavigationPanelContext';
3030
import { signOut, sync, syncErrorTracker } from '@/library/powersync/ConnectionManager';
31-
import { usePowerSync } from '@powersync/react';
31+
import { usePowerSync, useStatus } from '@powersync/react';
3232
import { useNavigate } from 'react-router-dom';
3333

3434
export default function ViewsLayout({ children }: { children: React.ReactNode }) {
3535
const powerSync = usePowerSync();
3636
const navigate = useNavigate();
3737

38-
const [syncStatus, setSyncStatus] = React.useState(sync.syncStatus);
38+
const syncStatus = useStatus();
3939
const [syncError, setSyncError] = React.useState<Error | null>(null);
4040
const { title } = useNavigationPanel();
4141

@@ -86,15 +86,6 @@ export default function ViewsLayout({ children }: { children: React.ReactNode })
8686
[powerSync]
8787
);
8888

89-
React.useEffect(() => {
90-
const l = sync.registerListener({
91-
statusChanged: (status) => {
92-
setSyncStatus(status);
93-
}
94-
});
95-
return () => l();
96-
}, [powerSync]);
97-
9889
React.useEffect(() => {
9990
const l = syncErrorTracker.registerListener({
10091
lastErrorUpdated(error) {

0 commit comments

Comments
 (0)