Closed bimusiek closed 10 months ago
Additional advantage for us is ability to have 2 Realms. Basically we have one Realm.Sync and another Realm.Local that is used as a replacement for memory heavy workloads. But we don't want to sync that one.
With these functions, we could have 2 realm instances with react functionality.
@bimusiek we expose a creatRealmContext
method, which allows you to expose multiple realms.
This takes a Realm configuration as an argument and returns an object containing the RealmProvider
and hooks associated with the Realm you are configuring.
Is this sufficient for your use-case?
Ah, right. Yes, that would probably be enough. Unfortunately due to the way we bundle our app for Electron & React Native, we still cannot use the included library as it imports Realm
directly. And we need to do some workaround with require()
for Electron so it imports it from Node
environment rather than Webpack bundle. (because then it tries to bundle RN inside)
Closing the comment for now.
we need to do some workaround with require() for Electron so it imports it from Node environment rather than Webpack bundle. (because then it tries to bundle RN inside)
@bimusiek I'd be interested to know if you've created an issue for this and if this issue is also experienced with realm@12
.
@kraenhansen No issue as it is old workaround from even before Realm was acquired by Mongo. We have the task on our upcoming work to update from Realm@11 to @12. I will check if workaround is not needed, if that won’t be a case I will create the issue.
update from
realm@11
to@12
That should be seamless, please let os know if it's not! 😊
@bimusiek I did recently create an electron
example to ease integration with realm
. Maybe it's helpful?
https://github.com/realm/realm-js/tree/main/examples/electron-todo-list
@takameyer @kraenhansen I am into the process of upgrade and besides some typing issues it went quite smooth. I got rid of our custom require()
workaround.
But I am getting error in Electron on renderer side:
Error: Cannot find module 'realm'
And in devserver:
Package path . is not exported from package
And I have no clue why this could be happening.
And the React Native packager throws:
error: Error: Unable to resolve module realm/realm-constants.json from /Users/bimusiek/Developer/FreeYourMusic/app/node_modules/.pnpm/realm@12.3.0_react-native@0.71.11/node_modules/realm/dist/bundle.react-native.js:
Ok, I was missing craco
and the webpack external configuration for Electron.
There is still one small issue: https://github.com/realm/realm-js/issues/6270 but I was able to patch it on my side by creating the missing file manually.
Problem
We want to slowly migrate our codebase to @realm/react. Currently, we have deeply integration of Realm into our React app using our own code.
We would love to gradually migrate, thus we need ability to pass our own
useRealm
, but bothcreateUseQuery
,createUseObject
are not exported.Solution
Simply export both
createUseQuery
,createUseObject
Alternatives
Currently we do pnpm patching to export both those functions.
How important is this improvement for you?
I would like to have it but have a workaround
Feature would mainly be used with
Atlas Device Sync