MCPcopy Create free account
hub / github.com/dailydotdev/apps / useQueryState

Function useQueryState

packages/shared/src/hooks/utils/useQueryState.ts:21–39  ·  view source on GitHub ↗
({
  key,
  defaultValue,
}: UseQueryStateProps<T>)

Source from the content-addressed store, hash-verified

19}
20
21export const useQueryState = <T>({
22 key,
23 defaultValue,
24}: UseQueryStateProps<T>): UseQueryState<T> => {
25 const client = useQueryClient();
26 const { data = defaultValue, ...rest } = useQuery<T>({
27 queryKey: key,
28 queryFn: () => client.getQueryData<T>(key) ?? defaultValue,
29 ...disabledRefetch,
30 initialData: defaultValue,
31 staleTime: Infinity,
32 });
33 const setState = useCallback(
34 (value: T) => client.setQueryData<T>(key, value),
35 [client, key],
36 );
37
38 return [data, setState, rest];
39};

Callers 7

MainFeedLayoutFunction · 0.90
SearchControlHeaderFunction · 0.90
ExploreSortDropdownFunction · 0.90
FeedExploreHeaderFunction · 0.90
OrganizationLayoutFunction · 0.90
AccountPageContainerFunction · 0.90
SettingsLayoutFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected