query: V4 does not log anything in react-native even when not in production

Describe the bug

When using react-query v4 with react-native, nothing is logged to the console, even when during development.

For instance when a query function throws an error, the error is not logged.

Your minimal, reproducible example

https://snack.expo.dev/@matthieugc/react-query-v4-no-logs-repro

Steps to reproduce

Have a query that throws an error

Expected behavior

Expected: the error is logged by react-query Happening: nothing is logged

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • React Native 0.69.3

react-query version

4.0.10

TypeScript version

No response

Additional context

Here’s why this seems to be happenning:

The package.json for react-query (and query-core) v4 contains these fields:

https://github.com/TanStack/query/blob/1d9c2120ce0bcee95a047e90dbaee66f56b01646/packages/react-query/package.json#L13-L15

https://github.com/TanStack/query/blob/1d9c2120ce0bcee95a047e90dbaee66f56b01646/packages/query-core/package.json#L13-L15

And metro, the react-native bundler, uses the browser field in priority when it’s available

→ For react-query, it points to the UMD production build, where the default logger calls have been removed during bundling

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 16 (5 by maintainers)

Most upvoted comments

@TkDodo Yes, we can also bump the version of beta tag forcefully via actions menu to be greater than current main version. Whatever works for you.

@vanniewelt can you show this in a codesandbox reproduction please?

@TkDodo Unfortunately, I wasn’t able to reproduce this in codesandbox with simple react app. However, I created demo repository with Next.js: https://github.com/vanniewelt/react-query-no-logging-error-demo

Make sure you also manually specify "@tanstack/query-core": "^4.0.11-beta.5", Cause newer version is available and it installs the newest one.

@DamianOsipiuk I tried it and no luck