Hello everyone, I am new to developing Realm based aplications, and was following the documentation to sinc a React Native application to a Realm. If I create a new realm without syncing it it works fine, but when I proceed to log in anonymously and try creating the synced realm the application crashes with no explanation.
Here is the code I have written, the Schema I imported from the Realm interface in the SDK section, and also got the AppId. If anyone is able to tell me where I am going wrong I would highly appreciate it. Thank you all so much!
import React from 'react';
import { prescriptionSchema } from './Prescriptions'
import {
View,
Text,
TouchableOpacity
} from 'react-native';
import Realm from 'realm';
async function start() {
const appConfig = { id: 'appId', timeout: 10000 }
const app = new Realm.App(appConfig);
const credentials = Realm.Credentials.anonymous();
const user = await app.logIn(credentials);
try {
console.log([prescriptionSchema])
const realm = await Realm.open({
schema: [prescriptionSchema],
sync: {
user: user,
partitionValue: 'name',
},
})
}
catch (e) { console.log(e) }
}
class App extends React.Component {
render() {
start();
return (
<View>
<TouchableOpacity>
<Text>Temporary</Text></TouchableOpacity></View>
)
}
}
export default App