I am new to Realm and trying to read from the database.
I made an object schema called _AppRegistry which will have a single entry. If that entry exists, the app has been loaded before. If it does not, then the app does not need to be loaded.
I have been following the Quick Start guide for making the app, and I am stuck getting making the function that goes inside the RealmProvider tags.
My understand from the Quick Start guide is that I make a new function and put a tag inside my RealmProvider tags that match the function name, then the code should just return from there.
However, I am getting the following error:
ERROR Invariant Violation: View config getter callback for component `initialiseApp` must be a function (received `undefined`). Make sure to start component names with a capital letter.
This error is located at:
in initialiseApp (created by App)
in Unknown (created by App)
in RCTView (created by View)
in View (created by App)
in App
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
in ps2319(RootComponent), js engine: hermes
How do I connect to and read from the Realm database in my app?
Below is my main app function that I export as default
const App = () => {
//initDB();
const {RealmProvider, useRealm, useObject, useQuery} = createRealmContext({schema: [_AppRegistry, Attachments, ReceiptAttachments, Receipts, ReceiptTags, Tags]});
return (
<RealmProvider>
<initialiseApp />
</RealmProvider>
);
};
// Other code...
export default App;
And my initialiseApp function looks like this:
function initialiseApp() {
const appRegistry = useObject(_AppRegistry, 0);
if(appRegistry == null){
return(
<View>
<Text>App Registry is not set up!</Text>
</View>
);
}else{
return(
<View>
<Text>App Registry is set up!</Text>
</View>
);
}
}
I solved my own problem by reading...
Make sure to start component names with a capital letter.
So I changed "initialiseApp" to "InitialiseApp" and then that error disappeared!