Find path for Realm file with Realm React Native to use with Realm Browser

前端 未结 4 1727
野性不改
野性不改 2020-12-31 19:10

On iOS, it is possible to inspect the contents of a Realm database by opening the corresponding file with the Realm Browser. The path to that file can be printed by using th

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-31 19:23

    To elaborate on Daniel Mesa's answer:

    In your react native class (assuming ES6 here) below your import lines (above the class definition) add the following:

    const Realm = require('realm');
    

    Then add a componentDidMount function and log the Realm default path:

      componentDidMount() {
        console.log('REALM PATH', Realm.defaultPath);
      }
    

    This should then output the realm db path in the console log (debug your react native app).

提交回复
热议问题