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

Function Characters

examples/solid/batching/src/index.tsx:21–63  ·  view source on GitHub ↗
(props: { ids: Array<number> })

Source from the content-addressed store, hash-verified

19})
20
21function Characters(props: { ids: Array<number> }) {
22 const characters = useQueries(() => ({
23 queries: props.ids.map((id) => charactersQueries.detail(id)),
24 }))
25
26 return (
27 <Index each={characters}>
28 {(character) => (
29 <Switch>
30 <Match when={character().status === 'pending'}>Loading...</Match>
31 <Match when={character().status === 'error'}>Error...</Match>
32 <Match when={character().data === null}>Not found ...</Match>
33 <Match when={character().data}>
34 {(data) => (
35 <div style={{ display: 'flex' }}>
36 <img
37 width={100}
38 height={100}
39 alt={data().image}
40 src={data().image}
41 />
42 <div style={{ 'padding-left': '10px', 'text-align': 'left' }}>
43 <h5 style={{ 'margin-top': 0, 'margin-bottom': '5px' }}>
44 {data().name} (#{data().id})
45 </h5>
46 <p style={{ 'margin-top': 0, 'margin-bottom': '2px' }}>
47 Status: {data().status}
48 </p>
49 <p style={{ 'margin-top': 0, 'margin-bottom': '2px' }}>
50 Species: {data().species}
51 </p>
52 <p style={{ 'margin-top': 0, 'margin-bottom': '2px' }}>
53 Gender: {data().gender}
54 </p>
55 </div>
56 </div>
57 )}
58 </Match>
59 </Switch>
60 )}
61 </Index>
62 )
63}
64
65function App() {
66 const [ids, setIds] = createSignal<Array<number>>([])

Callers

nothing calls this directly

Calls 1

useQueriesFunction · 0.90

Tested by

no test coverage detected