Realm does not synchronize records

Hi,

I am working on a React Native app, but unfortunately the synchronization between the app and Atlas is not working. The structure of my app follows exactly the template: https://www.mongodb.com/docs/realm/sdk/react-native/bootstrap-with-expo/

<AppProvider id={process.env.REALM_APP_ID}>
    <UserProvider fallback={<SignIn />}>
        <RealmProvider sync={{
            flexible: true,
            onError: error => console.error(error)
        }}>
            <App />
        </RealmProvider>
    </UserProvider>
</AppProvider>

Nevertheless, I don’t get any results with useQuery(), although records are available in Atlas.

const data = useQuery(Data)
console.log(data.length)

==> 0

I am on:

  • @realm/react”: “^0.4.1”
  • “realm”: “^11.3.1”

In MongoDB Compass I can see that a collection “state_data” has been created in the database “_realm_sync…”. Why can’t I access the data? What can be the reason for this?

Many greetings

Quick check: Have you followed the steps in this guide and changed e.g. the App ID (generating via realm-cli should get this right automatically)?

1 Like

I was able to solve the issue by subscribing to the object:

realm.subscriptions.update(mutableSubs => {
mutableSubs.add(realm.objects(…))
})

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