0

I have set up a react native monorepo using Yarn Workspaces. The goal would be to write one App as core, and the versions for different platforms would be siblings of core in the monorepo and would import core's App and just inject different dependencies based on what the platforms support.

Structure

monorepo
  -- core
  -- A (imports core)
  -- B (imports core)

On A I am trying to build for Web using react-native-web, Core is compiled using TSC and imported as a module in A. The problem is that Core uses React Query as a dependency, but it is nohoisted and installed separately in A. In the browser, the interpreter reaches some code from Core that accesses a constructor from React Query and throws an error.

Debugging I see that the result of require("@tanstack/react-query") results in this react_query_1: "/static/media/index.0fc0c3105e6c3255a746.cjs" and new react_query_1.QueryClient() throws as expected an error that QueryClient is not a constructor.

What could be wrong here?

1
  • this is an indication that you have multiple versions of react-query installed. Commented May 1 at 14:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.