-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
Goals
Create a simple Realm App and saving some data.
Expected Results
After adding realm to project and config it, Saves data
Actual Results
Realm object constructor must not return another value
<!--- What happened instead? -->
<!--- e.g. the stack trace of a crash -->
Steps to Reproduce
- Create a new React Native project
- add realm and lodash as dependencies
- add below codes
Code Sample
SaleTX.js
import _ from 'lodash' class RealmBase {} RealmBase.prototype.refAsArray = function(ref) { return _.keys(this[ref]).map(key => this[ref][key]) } class SaleTX extends RealmBase { get json() { let result = { id: this.id, merchantId: this.merchantId, }; return result; } } SaleTX.schema = { name: 'SaleTX', primaryKey: 'id', properties: { id: { type: 'string', indexed: true }, merchantId: { type: 'string', optional: true }, } }; export { SaleTX };
App.js
import React from 'react'; import { View } import Realm from 'realm'; import { SaleTX } from './SaleTX'; class App extends React.Component { constructor(props) { super(props); } componentDidMount (){ const realm = new Realm({ schema: [ SaleTX, ], }); let sale = realm.write(() => { realm.create('SaleTX', { merchantId: '54', id: '1' }); }); } render () { return( <View /> ) } }
Version of Realm and Tooling
- Realm JS SDK Version: 6.0.2
- React Native: 0.62.2
- Client OS & Version: Win 10 or Mac High Sierra