realm-js: only Android: Cannot access realm that has been closed(realm react)
How frequently does the bug occur?
All the time
Description
RealmContext.js
import { ContactInfo, Room, RoomBackground, RoomDetail, RoomMessage, Summary } from "../database/RealmSchemas"
import { Realm, createRealmContext } from '@realm/react'
const config = {
schema: [Room.schema,
ContactInfo.schema,
RoomDetail.schema,
RoomBackground.schema,
Summary.schema,
RoomMessage.schema],
}
export default createRealmContext(config)
Other class
import RealmContext from '../../context/RealmContext'
const { useRealm, useQuery } = RealmContext
export class....{
const realm = useRealm()
... get data....
Stacktrace & log output
ReactNativeJS: { [Error: Cannot access realm that has been closed.
Can you reproduce the bug?
Yes, always
Reproduction Steps
as Description Define realm context get Realm instance => const { useRealm } = realmContext create realm => const realm = useRealm() query data
Version
“realm”: “^10.18.0”, “@realm/react”: “^0.3.0”,
What SDK flavour are you using?
Local Database only
Are you using encryption?
No, not using encryption
Platform OS and version(s)
Android simulator sdk 30
Build environment
Which debugger for React Native: … npm -v not ok Use npm v8.18.0 node -v not ok Use node v17.9.1 (current: v17.8.0)
Cocoapods version
android problem
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 32 (9 by maintainers)
This is not compatible with Realm v10 on Android. We have a release candidate for v11.
Can you try:
Thanks solved the issue, I had realm 10.20.0-beta.5 and react-native-reanimated 2.5.0
Ahh, i found the problem, the scheme class does not contain import Realm, but I dont know why IOS does not make crash, only Android. Im really thanks you for your help Here is my RealmSchema:
@fukemy That code looks fine. I’m going to follow up with some questions.
Can you try and implement the
fallbackproperty on theRealmProvider? This makes sure the children are not rendered until the realm context is set. The following example should suffice:Are you using
realmin any other way outside of theuseRealmhook? If you, for example, open and close a realm within auseEffectthen this would also close therealmreturned from theuseRealmhook.thanks, i will try to make a small project to reproduce