Skip to content

Missing dependency on react-dom leads to runtime errors when using yarn berry #3534

Closed
@SoftMemes

Description

@SoftMemes

Describe the bug

When using react-query in a project using yarn berry (3+), in combination with workspace, then dependencies are no longer shared across the project and instead only direct dependencies of each library are visible to it.

As a result, using react-query from a next.js project and client side rendering fails as it is unable to import react-dom, which does not appear as a dependency, or a peer dependency, in react query.

It is possible to work around this by making react and react-dom dependencies of the top level project in a yarn workspace.

Your minimal, reproducible example

N/A

Steps to reproduce

  1. Create a new yarn 3 workspace, with a module containing a next.js project with dependency on react-query
  2. Attempt to use react-query in a client side component of this project
  3. Observe that react-query fails to find react-dom, as it is not a dependency of react-query and thus invisible to it under yarn 3 resolution rules

Expected behavior

React-dom is resolved as dependency of react-query, or alternatively, a react-dom specific version of / addon to react-query is required in a react-dom environment.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • Linux Ubuntu 18, any browser

react-query version

3.35.0

TypeScript version

4.6.3

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions