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

Function useQueryState

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

Source from the content-addressed store, hash-verified

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

Callers 13

MainFeedLayoutFunction · 0.90
SearchControlHeaderFunction · 0.90
ExploreSortMenuFunction · 0.90
FeedExploreTabsFunction · 0.90
FeedExploreHeaderFunction · 0.90
useSetFeedExplainFunction · 0.90
useFeedExplainModeFunction · 0.90
useFeedTuneStateFunction · 0.90
FeedLayoutProviderFunction · 0.90
OrganizationLayoutFunction · 0.90
AccountPageContainerFunction · 0.90
SettingsLayoutFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected