I can't get the results of any query when not debugging, but works perfectly when debugging
Also I noticed that Realm is behaving very differently according to wither debugging or not
This is just a summary of the idea :
I'm printing object.constructor.name
to find the type of the object
When debugging (Remotely using Chrome or Safari) :
let realm = new Realm(config);
realm.constructor.name --> will print (Realm)
let dogs = realm2.objects('Dog');
dogs.constructor.name --> will print (Results)
(inserting few dogs)
for (let oneDog of dogs) {
oneDog.constructor.name --> will print (RealmObject)
} --> works perfectly
But when not debugging everything is different:
let realm = new Realm(config);
realm.constructor.name --> will print (Object)
let dogs = realm2.objects('Dog');
dogs.constructor.name --> will print nothing
(inserting few dogs)
for (let oneDog of dogs) {
oneDog.constructor.name --> not compiled
} --> will give the error below
TypeError: undefined is not a function (evaluating ‘_iterator[typeof
Symbol === “function” ? Symbol.iterator : “@@iterator”]()')
I'm not sure if it's a bug or a problem with my codes
Version of Realm and Tooling
- Realm JS SDK Version: 2.10.0
- React Native: 0.55.4
- Client OS & Version: Running on Android device 8.0
- Which debugger for React Native: Chrome
Full code :
import React, { Component } from 'react';
import { View, Text } from 'react-native';
const Realm = require('realm');
export default class Page3Screen extends Component {
state = { messege : 'no messege' }
componentWillMount() {
const config = {
schema: [{ name: 'Dog', properties: { name: 'string' } }],
};
let realm = new Realm(config);
console.log(realm.constructor.name);
this.setState({ messege: realm.constructor.name });
realm.write(() => {
realm.create('Dog', { name: 'Zozo' });
});
let dogs = realm.objects('Dog');
// console.log(dogs.constructor.name);
// this.setState({ messege: dogs.constructor.name });
// for (let oneDog of dogs) {
// console.log(oneDog.constructor.name);
// this.setState({ messege: oneDog.constructor.name });
// }
}
render() {
return (
<View style={{ alignSelf: 'stretch', flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>{this.state.messege}</Text>
</View>
);
}
}