File tree 1 file changed +5
-5
lines changed
demos/react-native-supabase-group-chat/src/providers
1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 1
1
import '@azure/core-asynciterator-polyfill' ;
2
2
import { PowerSyncContext , PowerSyncDatabase } from '@powersync/react-native' ;
3
3
import Logger from 'js-logger' ;
4
- import { ReactNode , useMemo } from 'react' ;
4
+ import { ReactNode , useEffect , useMemo } from 'react' ;
5
5
6
6
import { useAuth } from './AuthProvider' ;
7
7
import { Connector } from '../lib/connector' ;
@@ -20,9 +20,11 @@ export const PowerSyncProvider = ({ children }: { children: ReactNode }) => {
20
20
database : { dbFilename : 'test.sqlite' }
21
21
//location: 'optional location directory to DB file'
22
22
} ) ;
23
-
24
23
powerSync . init ( ) ;
24
+ return powerSync ;
25
+ } , [ ] ) ;
25
26
27
+ useEffect ( ( ) => {
26
28
if ( isSyncEnabled ) {
27
29
powerSync
28
30
. connect ( connector )
@@ -34,9 +36,7 @@ export const PowerSyncProvider = ({ children }: { children: ReactNode }) => {
34
36
. then ( ( ) => console . log ( 'not connected' ) )
35
37
. catch ( console . error ) ;
36
38
}
37
-
38
- return powerSync ;
39
- } , [ isSyncEnabled ] ) ;
39
+ } , [ isSyncEnabled , powerSync ] ) ;
40
40
41
41
return < PowerSyncContext . Provider value = { powerSync } > { children } </ PowerSyncContext . Provider > ;
42
42
} ;
You can’t perform that action at this time.
0 commit comments