React-query: Add option to not log to console

Created on 12 Feb 2020  路  1Comment  路  Source: tannerlinsley/react-query

First of all: I love this library. 鉂わ笍

Current situation

Failed queryFns will be catched and then logged to the console with console.error.

Problem

I'm using react-query with React Native, which shows all console.error as a big red box in development mode. I expect that some of my requests can throw an error (e.g. if it's an 401 Unauthorized). But even if I'm expecting and handling those errors, they will appear as big red box because it has been logged with console.error.

image

I could also imagine that when I'm using react-query inside the browser, I maybe don't want errors to be logged to the console.

Current workaround

I'm currently overriding console.error to ignore all those errors. 馃檲

Proposed solution

Maybe logging could be an opt-out? Or opt-in, like a global debug mode?

Most helpful comment

Now you can replace the console object used internally to log, warn and error. Enjoy!

>All comments

Now you can replace the console object used internally to log, warn and error. Enjoy!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lgenzelis picture lgenzelis  路  4Comments

aleksandarcrvc picture aleksandarcrvc  路  3Comments

ivowork picture ivowork  路  5Comments

alveshelio picture alveshelio  路  6Comments

tiagofernandez picture tiagofernandez  路  3Comments