Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use useDebugValue in useQuery and useMutation hooks #2500

Merged

Conversation

kaankeskin
Copy link
Contributor

@kaankeskin kaankeskin commented Jul 7, 2022

Fixes #2492
This PR uses useDebugValue for better debugging in React DevTools.

This is how a DebugValue is shown for a useQuery hook in React DevTools:
image

and this is how a DebugValue is shown for a useMutation hook in React DevTools:
image

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 7, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 606b177:

Sandbox Source
Vanilla Configuration
Vanilla Typescript Configuration
rsk-github-issues-example Configuration
@examples-query-react/basic Configuration
@examples-query-react/advanced Configuration
@examples-action-listener/counter Configuration

@netlify
Copy link

netlify bot commented Jul 7, 2022

Deploy Preview for redux-starter-kit-docs ready!

Name Link
🔨 Latest commit 606b177
🔍 Latest deploy log https://app.netlify.com/sites/redux-starter-kit-docs/deploys/62c76a76510ab40008951ef9
😎 Deploy Preview https://deploy-preview-2500--redux-starter-kit-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@markerikson
Copy link
Collaborator

Very nice!

Looking at the React docs, would it be worth using the "deferred formatting" option here?

https://reactjs.org/docs/hooks-reference.html#defer-formatting-debug-values

@kaankeskin
Copy link
Contributor Author

kaankeskin commented Jul 8, 2022

It does not worth I think. Because, I am passing an object to useDebugValue. I may use JSON.stringify with it but it makes debugging harder since it shows it as a string and the object is not "collapsible".
Here like that:
image

@markerikson
Copy link
Collaborator

Let's get this in!

@markerikson markerikson merged commit 064e9cc into reduxjs:master Aug 11, 2022
@kaankeskin
Copy link
Contributor Author

Yay! Thanks for merging this. Having a commit in a project I love made me really happy :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RTK Query hooks should use useDebugValue to better display data
2 participants