MCPcopy Create free account
hub / github.com/alphaXiv/OpenResearch / useQuery

Function useQuery

ui/tests/fileRestore.test.mjs:76–87  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

74 const queries = queryModules(api);
75 const queryHooks = {
76 useQuery(options) {
77 const [, render] = react.useState(0);
78 const key = JSON.stringify(options.queryKey);
79 react.useEffect(() => queries.client.getQueryCache().subscribe((event) => {
80 if (JSON.stringify(event.query.queryKey) === key) render((n) => n + 1);
81 }), [key]);
82 react.useEffect(() => {
83 if (options.enabled !== false) void queries.client.fetchQuery(options).catch(() => {});
84 }, [key, options.enabled]);
85 const state = queries.client.getQueryState(options.queryKey);
86 return { data: state?.data, error: state?.error, isPending: !state || state.status === "pending" };
87 },
88 };
89 function loadHook(name) {
90 const source = readFileSync(new URL(`../src/${name}.ts`, import.meta.url), "utf8");

Callers 15

ProjectsPageFunction · 0.85
useLatexCompileFunction · 0.85
useFileVersionFunction · 0.85
RuntimeRootFunction · 0.85
AppFunction · 0.85
useOverleafSyncFunction · 0.85
HarnessesTabFunction · 0.85
K8sSectionFunction · 0.85
ModalSectionFunction · 0.85
SshSectionFunction · 0.85
SlurmSectionFunction · 0.85
RaySectionFunction · 0.85

Calls 2

subscribeMethod · 0.80
renderFunction · 0.70

Tested by

no test coverage detected