Typing custom hook with selector #4086
Unanswered
crieggalder
asked this question in
Q&A
Replies: 1 comment
-
see: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all - I'm trying to correctly type a custom hook wrapping useQuery with a selector. The custom hook does a few things:
My goal is to type this custom hook to accept a generic type e.g.
Post
, and return a data object that is an array of that type e.g.Post[]
, along with the rest of useQuery's standard return. How should I do that?Here's my current code which is wrong in many places - I'm new to TS and it feels like I'm just misunderstanding how to use generics in this context/how the library uses them.
Thank you!!
Beta Was this translation helpful? Give feedback.
All reactions