karrthikarya
karrthikarya•13mo ago

Convex with React Native without Expo

Is the support for projects outside of expo not present since the documentation only mentions expo
9 Replies
erquhart
erquhart•13mo ago
I use Expo so I can't say from experience, but it should work fine with React Native. Happy to help troubleshoot if you give it a shot and run into anything. Just after a quick scan, I believe everything in the Expo quickstart applies to a non-Expo React Native project except the first step (generating the expo app). Not sure if there are differences in the Babel step, but Expo and React Native both use Metro, so I think they both use Babel as well.
saicharan
saicharan•12mo ago
error Unable to resolve module react-dom from /Users/saicharan/Documents/projects/healthbound/ui/healthbound/node_modules/.pnpm/convex@1.10.0_react@18.2.0/node_modules/convex/dist/cjs/react/client.js: react-dom could not be found within the project or in these directories:
node_modules/.pnpm/convex@1.10.0_react@18.2.0/node_modules/convex/node_modules
node_modules/.pnpm/convex@1.10.0_react@18.2.0/node_modules
node_modules/.pnpm/node_modules
node_modules
../../../node_modules
41 | var import_react = __toESM(require("react"), 1);
42 | var import_values = require("../values/index.js");
> 43 | var import_react_dom = __toESM(require("react-dom"), 1);
| ^
44 | var import_use_queries = require("./use_queries.js");
45 | var import_common = require("../common/index.js");
46 | var import_api = require("../server/api.js");.
error Unable to resolve module react-dom from /Users/saicharan/Documents/projects/healthbound/ui/healthbound/node_modules/.pnpm/convex@1.10.0_react@18.2.0/node_modules/convex/dist/cjs/react/client.js: react-dom could not be found within the project or in these directories:
node_modules/.pnpm/convex@1.10.0_react@18.2.0/node_modules/convex/node_modules
node_modules/.pnpm/convex@1.10.0_react@18.2.0/node_modules
node_modules/.pnpm/node_modules
node_modules
../../../node_modules
41 | var import_react = __toESM(require("react"), 1);
42 | var import_values = require("../values/index.js");
> 43 | var import_react_dom = __toESM(require("react-dom"), 1);
| ^
44 | var import_use_queries = require("./use_queries.js");
45 | var import_common = require("../common/index.js");
46 | var import_api = require("../server/api.js");.
this is the error i'm getting with same implemenation just instead of react-native-dotenv i'm using react-native-config
erquhart
erquhart•12mo ago
hmm yeah you don't want react-dom attempting to load in a native app, curious what's happening there
saicharan
saicharan•12mo ago
my bad i missed react-dom
erquhart
erquhart•12mo ago
Actually I see it in my dependencies too, so convex must be conditionally loading it for web only oh that's not a runtime error from react-dom, it's saying it can't resolve the module hmm Not sure if what you're seeing is pnpm specific, but I'd try: 1. nuking node_modules and reinstalling 2. if 1 doesn't work, as a troubleshooting step, try installing react-dom as a direct dependency
saicharan
saicharan•12mo ago
that's what I did, i see no errors.. will try mutation and query now..
sshader
sshader•12mo ago
Convex should work with non-expo React Native, but the react dom dependency is needed. The Convex React client uses ReactDOM.unstable_batchedUpdates (which was necessary for compatibility with older version of React)
saicharan
saicharan•12mo ago
Its working 🙌
erquhart
erquhart•12mo ago
🙌

Did you find this page helpful?