Removing callbacks from useQuery
Is this the right patch to remove the callbacks from
useQuery's options?
currently trying to trigger something that will lint or typecheck with an error whenever I use those callbacks - I added https://github.com/gund/eslint-plugin-deprecation, but it seems the react queries are too complicated for it to detect those doc comments...12 Replies
other-emeraldOPโข3y ago
looks like the eslint plugin i used doesn't support detecting deprecated object property assignments, just consumption of those deprecated properties
https://github.com/gund/eslint-plugin-deprecation/issues/13
GitHub
No warnings about setting a deprecated property ยท Issue #13 ยท gund/...
type T = { new?: string; /** @deprecated */ old?: string; }; const myT: T = { // I'd expcect an ESLint warning here, but there is none old: 'value' }; console.info(myT.old); // I only g...
other-emeraldOPโข3y ago
cc @TkDodo ๐ฎ if i can poke :p
was trying to use
pnpm patch to remove the callbacks from the useQuery options type before upgrading to v5, but I seem to not have the right patchstormy-goldโข3y ago
yeah that diff looks right
other-emeraldOPโข3y ago
๐
somehow it still typechecks
other-emeraldOPโข3y ago

other-emeraldOPโข3y ago
applying the above patch w/ pnpm :shrug:

other-emeraldOPโข3y ago
oh well, ig i'll just manually work on it / eventually upgrade to v5
stormy-goldโข3y ago
Ah you probably shouldn't patch the src dir
other-emeraldOPโข3y ago
derp
yup that did it ๐
tyyy
is there an ergonomic way to replicate this w/o callbacks?
basically we have an opaque
prevCursor & so we serialize the last request as a cache data under that cursor... kinda hacky tbh but it works with our particular setup
ah...
would be cool if this was a "feature flag" in the current releases, so people could remove these callbacks before v5other-emeraldOPโข3y ago
other-emeraldOPโข3y ago
thx for the help again ๐
other-emeraldOPโข3y ago
Dominik ๐บ๐ฆ (@TkDodo)
๐โโ๏ธReact tip: I think most implementations of
usePrevious will write to a ref in an effect and return it, but the rules of react advise us to not read refs during render.
Here is my implementation, based on what I learned in the new react docs (https://t.co/JltAPkVKi4):Likes
286

Twitter
