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

feat: record SWR data with useDebugValue #37

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

koba04
Copy link
Owner

@koba04 koba04 commented Nov 16, 2021

useDebugValue can be used to display values in React Developer Tools.
This PR is to add useDebugValue in SWR DevTools middleware to display SWR data.

image

@vercel
Copy link

vercel bot commented Nov 16, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/koba04/swr-devtools/mSAcapc39bwByCihTddo1wNvEmfK
✅ Preview: https://swr-devtools-git-feat-record-swr-data-with-usedebugvalue-koba04.vercel.app

@koba04
Copy link
Owner Author

koba04 commented Nov 18, 2021

I've noticed that this approach might have extra re-render because SWR tracks the usage of the response data by getter functions.
https://github.com/vercel/swr/blob/98556e12d394c819fd69535ad5fe0dd980e79fe9/src/use-swr.ts#L487-L501

This code would mark the data as used even if the actual implementation didn't access the data.

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.

1 participant