MCPcopy Create free account
hub / github.com/TanStack/query / QueryRow

Function QueryRow

packages/query-devtools/src/Devtools.tsx:1374–1481  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

1372}
1373
1374const QueryRow: Component<{ query: Query }> = (props) => {
1375 const theme = useTheme()
1376 const css = useQueryDevtoolsContext().shadowDOMTarget
1377 ? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
1378 : goober.css
1379 const styles = createMemo(() => {
1380 return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
1381 })
1382
1383 const { colors, alpha } = tokens
1384 const t = (light: string, dark: string) => (theme() === 'dark' ? dark : light)
1385
1386 const queryState = createSubscribeToQueryCacheBatcher(
1387 (queryCache) => queryCache().get(props.query.queryHash)?.state,
1388 true,
1389 (e) => e.query.queryHash === props.query.queryHash,
1390 )
1391
1392 const isDisabled = createSubscribeToQueryCacheBatcher(
1393 (queryCache) =>
1394 queryCache().get(props.query.queryHash)?.isDisabled() ?? false,
1395 true,
1396 (e) => e.query.queryHash === props.query.queryHash,
1397 )
1398
1399 const isStatic = createSubscribeToQueryCacheBatcher(
1400 (queryCache) =>
1401 queryCache().get(props.query.queryHash)?.isStatic() ?? false,
1402 true,
1403 (e) => e.query.queryHash === props.query.queryHash,
1404 )
1405
1406 const isStale = createSubscribeToQueryCacheBatcher(
1407 (queryCache) => queryCache().get(props.query.queryHash)?.isStale() ?? false,
1408 true,
1409 (e) => e.query.queryHash === props.query.queryHash,
1410 )
1411
1412 const observers = createSubscribeToQueryCacheBatcher(
1413 (queryCache) =>
1414 queryCache().get(props.query.queryHash)?.getObserversCount() ?? 0,
1415 true,
1416 (e) => e.query.queryHash === props.query.queryHash,
1417 )
1418
1419 const color = createMemo(() =>
1420 getQueryStatusColor({
1421 queryState: queryState(),
1422 observerCount: observers(),
1423 isStale: isStale(),
1424 }),
1425 )
1426
1427 const getObserverCountColorStyles = () => {
1428 if (color() === 'gray') {
1429 return css`
1430 background-color: ${t(colors[color()][200], colors[color()][700])};
1431 color: ${t(colors[color()][700], colors[color()][300])};

Callers

nothing calls this directly

Calls 13

useThemeFunction · 0.90
useQueryDevtoolsContextFunction · 0.90
getQueryStatusColorFunction · 0.90
isStaleFunction · 0.85
getMethod · 0.80
isDisabledMethod · 0.80
isStaticMethod · 0.80
isStaleMethod · 0.80
getObserversCountMethod · 0.80
darkStylesFunction · 0.70

Tested by

no test coverage detected