-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: Better structural sharing in tanstack-query #6306
Comments
Happy to have our react-query package to include a utility function that worked for this, would you be down to making it happen? |
Happy to take a stab at it! Two main questions for which direction to go:
@juanrgon happy to get your input on this :) |
Personally, I would prefer this to be built-in behavior of
I don't think it should be specific to I like @gaearon's suggestion of using a subset of Structured Clone Javascript Types: TanStack/query#6481 (comment) |
(please don't @ random people that aren't related to thread or tRPC, it's not nice to their GitHub notifications) |
@KATT I DMed you on discord :) |
Describe the feature you'd like to request
TRPC uses
superjson
by default to provide types beyond json-serializable ones, however this breaks default structural sharing in tanstack-query.The most obvious impact is that any native
Date
field in a response object will cause the data object returned by auseQuery
hook to have a different identity.Discussion for context: TanStack/query#6481
Describe the solution you'd like to see
Given that trpc uses
superjson
by default, I think I'd like to see a defaultstructuralSharing
function that handles equality for the types handled by superjson.Describe alternate solutions
replaceEqualDeep
equivalent functions, since the logic of the two operations are tightly related. Using two different algos could introduce very hard-to-detect bugs.Additional information
Adding a default function would be a breaking change :)
I don't know what the performance impact of everything would be.
👨👧👦 Contributing
Funding
The text was updated successfully, but these errors were encountered: