useReactiveVar
Apollo Client API reference
Reads the value of a reactive variable and re-renders the containing component whenever that variable's value changes. This enables a reactive variable to trigger changes without relying on the useQuery hook.
Example
JavaScript
1 import { makeVar, useReactiveVar } from "@apollo/client";
2 export const cartItemsVar = makeVar([]);
3
4 export function Cart() {
5 const cartItems = useReactiveVar(cartItemsVar);
6 // ...
7 }Signature
TypeScript
1useReactiveVar<T>(
2 rv: ReactiveVar<T>
3): TParameters
Result
The current value of the reactive variable.T