-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
How frequently does the bug occur?
All the time
Description
As a user, if I do the following const foo = useObject('foo', fooId) and foo is initially not in the database, I would expect the hook to re-render if the object with fooId is later inserted into realm. This is how most state libraries work in react. In practice, the way useObject works is that it will not re-render. The way to solve this is to do the following in the useObject hook:
Try to get the object by primary key. If it exists setup a listener. Otherwise listen to its collection. In the collection listener callback, if the object has been inserted, setup the listener.
Stacktrace & log output
No response
Can you reproduce the bug?
Yes, always
Reproduction Steps
No response
Version
main
What SDK flavour are you using?
Local Database only
Are you using encryption?
No, not using encryption
Platform OS and version(s)
ios
Build environment
No response
Cocoapods version
No response
- duplicates
-
RJS-1605 Realm/React. If i subscribe to a not-yet existing object with `useObject` and it comes into existence, the view is not re-rendered (no event for this)
- Closed