1 / 1
May 2024

I have developed react native app to use realm so in case of internet not available then user can do local operation on device and as soon as internet is back then data is sync and updated on live mongoDB atlas database. I have a dedicated backend in node.js where I’m using JWT authentication method. The app connects fine and my backend allows access where that jwt token is used in realm and its also connected however, the app stays on login screen is not redirected to dashboard screen. Following is code of my realm wrapper component for review. Need advise/ suggestion regarding what I’m missing so that I can resolve the issue.

import React, {useContext, useEffect, useState} from 'react'; import {AppProvider, UserProvider, RealmProvider} from '@realm/react'; import {ActivityIndicator, StyleSheet, View} from 'react-native'; import {RealmQuickSale, RealmProduct} from '../modal/sales'; import Config from '../../atlasConfig.json'; import AppNavigator from '../navigation/AppNavigator'; import LoginScreen from './components/LoginScreen'; const RealmScreen = () => { const LoadingIndicator = () => { console.log('===== Falling Back to LoadingIndicator'); return ( <View style={styles.activityContainer}> <ActivityIndicator size="large" /> </View> ); }; return ( <AppProvider id={Config.appId} baseUrl={Config.baseUrl}> <UserProvider fallback={LoginScreen}> <RealmProvider schema={[RealmQuickSale, RealmProduct]} sync={{ flexible: true, onError: (_session, error) => { // Show sync errors in the console console.error(error); }, }} fallback={LoadingIndicator}> <AppNavigator /> </RealmProvider> </UserProvider> </AppProvider> ); }; const styles = StyleSheet.create({ activityContainer: { flex: 1, flexDirection: 'row', justifyContent: 'space-around', padding: 10, }, }); export default RealmScreen;