question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Realm returns blank when not using React Native Debugger

See original GitHub issue

Goals

I’m trying to add an entity into Realm and then read and list it in another scene.

Expected Results

The data that is read is supposed to be rendered as a list. It does happen but the data itself is not present.

Actual Results

The data is saved to the database and is subsequently read from the database. A single item is rendered to the list, but all its values are empty. When clicking the item, a new screen opens which showcases all the data from that specific item (the item itself only shows 2 of the details) This only happens if I’m not running the React Native debugger. I’ve generated the debug APK for testing purposes and the error still persisted.

Steps to Reproduce

I’m not sure what can be done to reproduce this. I’m saving one item to a schema and later reading it. The data is retrieved but all the values in it are empty.

Code Sample

1.This is the code that reads the data from the database. None of the values are undefined or null. This return the blank data when not using the debugger:

const data = realm.objects('Visita').filtered(`matricula == '${this.props.matricula}' AND idObra == ${this.props.data.id}`)
  1. This is the code that created the data prior to it being read in another page:
 getRealm()
                .then(realm => {
                    /*Some boilerplatecode*/
                    realm.write(() => {
                        realm.create('Visita', visita)
                    })
  1. This is the schema that is being added:
export default class VisitaSchema {
    static schema = {
        name: 'Visita',
        primaryKey: 'idVisita',
        properties: {
            idVisita: { type: 'int', indexed: true },
            descricao: 'string',
            latitude: 'string',
            longitude: 'string',
            matricula: 'string',
            idObra: 'int',
            data: 'string'
        }
    }
}

Version of Realm and Tooling

  • Realm JS SDK Version: ?
  • Node or React Native: ?
  • Client OS & Version: ?
  • Which debugger for React Native: ?/None

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:30 (8 by maintainers)

github_iconTop GitHub Comments

26reactions
Ervzzcommented, Jun 29, 2021

After a day of trying to get realm to work with a fresh react-native app, we’ve abandoned all hope. Best fix for this 2 year old issue is:

yarn remove realm

5reactions
steffenaggercommented, Sep 1, 2020

@manoj-makkuboy if you are using class models, please try extending from Realm.Object, like so:

class MyModel extends Realm.Object {
  ...
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Realm.objects() return empty objects on React Native
I used this function to persist the User. insertData = async (data) => { await Realm.open({schema: [ ...
Read more >
Troubleshooting - React Native
These are some common issues you may run into while setting up React Native. If you encounter something that is not listed here,...
Read more >
Realm: Create reactive mobile apps in a fraction of the time
Realm JavaScript enables you to efficiently write your app's model layer in a safe, persisted and fast way. It's designed to work with...
Read more >
Realm is not defined" when remote js debugging in React Native
When using flipper I did not get the Realm is undefined but the instance of the realm returned an empty object i.e "{}"....
Read more >
Realistic Realm - lessons learned after using it for 1.5 years
Realm has been known in the mobile (and not only) developers' community ... Swift), Xamarin (C#), and JavaScript (React Native, Node.js).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found