Relay Flashcards
useQueryLoader
Hook used to make it easy to safely load and retain queries. It will keep a query reference stored in state, and dispose of it when the component is disposed or it is no longer accessible via state.
What does useQueryLoader return?
and array of: [ queryReference, loadQuery, disposeQuery ]
what are the arguments useQueryLoader accepts?
query: GraphQL query specified using a graphql template literal.
initialQueryRef: [Optional] An initial PreloadedQuery to be used as the initial value of the queryReference stored in state and returned by useQueryLoader.
what is queryReference in the return of useQueryLoader?
the query reference, or null
what is loadQuery in the return of useQueryLoader?
a callback that, when executed, will load a query, which will be accessible as queryReference. If a previous query was loaded, it will dispose of it
what is disposeQuery in the return of useQueryLoader?
a callback that, when executed, will set queryReference to null and call .dispose() on it. It has type () => void