Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different behavior when debugging / not debugging #1883

Closed
MujtabaFR opened this issue Jun 20, 2018 · 4 comments
Closed

Different behavior when debugging / not debugging #1883

MujtabaFR opened this issue Jun 20, 2018 · 4 comments

Comments

@MujtabaFR
Copy link

MujtabaFR commented Jun 20, 2018

Hello,
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

When not debugging:

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

photo_2018-06-20_17-05-48

TypeError: undefined is not a function (evaluating ‘_iteratortypeof Symbol === “function” ? Symbol.iterator : “@@iterator”’)

I noticed the problem because I can't get the results of query from Realm when not debugging,
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>
    );
  }
}
@kneth
Copy link
Contributor

kneth commented Jun 25, 2018

The error message is related to facebook/react-native#15902.

@kneth kneth added the T-Help label Jun 25, 2018
@MujtabaFR
Copy link
Author

MujtabaFR commented Jun 27, 2018

Thanks .. the suggested updating the JSC version that ships with android solved the issue

@kneth
Copy link
Contributor

kneth commented Jun 28, 2018

@MujtabaFR Great to hear!

@FibreFoX
Copy link

@MujtabaFR I might have found a comment reflecting the different behaviour:
facebook/react-native#18426 (comment)

Meanwhile using the newer JSC-version on android helps a lot, especially when using newer versions of RN like 0.57.2 and above.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants