Maintaining sync realm between app screens



After user login - what is the best practice to access a synced realm in all my app screens (I use react-navigation)?

sync realm requires a user object in the configuration object.I tried using Realm.Sync.User.current but this raise an error when I initially launch the app as the user object is still empty (I created a separate file for the sync realm initialization which I import to all other pages/screens).

what is the best practice to do it ?

Thank you



@yuvalkro Typically you pass the realm reference to the next view controller, see here for an example tutorial:


Thank you Ian, helpful as always.
Understood your point.Trying to figure out the best practice to do it in react-native.


I have found that React context also works great for this in case anyone runs across this thread.