RealmProvider stuck in fallback spinner

Hi

I’m using @realm/react with flexible sync. My problem is after I login the app is stuck on the spinner from the fallback prop of the RealmProvider. However if I close and open the app again I see the correct data from DemoComponent.

Here is my code:

import React from 'react';
import {AppProvider, RealmProvider, UserProvider} from '@realm/react';

import LoginComponent from './App/Components/Views/Login';
import DemoComponent from './App/Components/Views/Demo';
import LoadingSpinner from './App/Shared/LoadingSpinner';
import {TemplateCategorySchema} from './App/RealmModels/schema';
import {TemplateCategory} from './App/RealmModels/realmClasses';
import {OpenRealmBehaviorType} from 'realm';

function App(): JSX.Element {
  const realmAccessBehavior: Realm.OpenRealmBehaviorConfiguration = {
    type: OpenRealmBehaviorType.DownloadBeforeOpen,
    timeOutBehavior: 'openLocalRealm',
    timeOut: 1000,
  };

  return (
    <AppProvider id={'dynamicforms-qa-jqtpx'}>
      <UserProvider fallback={LoginComponent}>
        <RealmProvider
          schema={[TemplateCategorySchema]}
          sync={{
            newRealmFileBehavior: realmAccessBehavior,
            existingRealmFileBehavior: realmAccessBehavior,
            onError: console.error,
            flexible: true,
          }}
          fallback={() => <LoadingSpinner />}>
          <DemoComponent />
        </RealmProvider>
      </UserProvider>
    </AppProvider>
  );
}

export default App;

I’ve tried using initialSubscription / adding subscriptions after, using/not using newRealmFileBehavior/existingRealmFileBehavior, using createRealmContext etc.

The spinner stays for minutes but if I close/open the app my data shows right away.

I’m not sure what I’m doing differently from https://www.mongodb.com/docs/realm/sdk/react-native/sync-data/configure-a-synced-realm/#add-a-query-to-the-list-of-subscriptions.

Thanks,

1 Like

Well this was a pbcak. In my LoginComponent I was calling app.logIn() twice while testing stuff and forgot about it. Once I removed the extra line it was fine.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.