Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 王国似乎不起作用_React Native_Realm - Fatal编程技术网

React native 王国似乎不起作用

React native 王国似乎不起作用,react-native,realm,React Native,Realm,我正在尝试在react原生android中使用realm,我只是想测试它是否正常工作。 它似乎保存了数据,因为它抛出了重复的primaryKey错误。 但是,realm.objects('Person')不返回数据,而是 Proxy [[Handler]] : Object [[Target]] : Results [[IsRevoked]] : false class Person {} Person.schema = { name: 'Person',

我正在尝试在react原生android中使用realm,我只是想测试它是否正常工作。 它似乎保存了数据,因为它抛出了重复的primaryKey错误。 但是,realm.objects('Person')不返回数据,而是

Proxy
[[Handler]]
:
Object
[[Target]]
:
Results
[[IsRevoked]]
:
false  

 class Person {}
    Person.schema = {
      name: 'Person',
      primaryKey: 'name',
      properties: {
        name: 'string',
        age: {type: 'int', default: 0},
      },
    };

    const realm = new Realm({schema: [Person],schemaVersion: 2});

// Write
    realm.write(() => {
      const savedPerson = realm.create('Person', {
        name: 'Hal Incanden1za',
        age: 17,
      });
    });
    console.log(realm.objects('Person'))

您从
realm.objects()
调用中获得的值不是一个普通数组,因此
console.log
可能没有达到您在这里期望的效果。尝试对其进行迭代。

可能是您试图在emulator上重新加载应用程序,而它试图覆盖已存储的数据。。请在刷新存储后重试或重新安装