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

Function App

examples/solid/batching/src/index.tsx:65–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

63}
64
65function App() {
66 const [ids, setIds] = createSignal<Array<number>>([])
67 const [idsToLoad, setIdsToLoad] = createSignal<Array<number>>([])
68 const [error, setError] = createSignal('')
69
70 return (
71 <div class="App">
72 <h2>Character fetcher</h2>
73 <div>
74 <label style={{ display: 'block' }}>
75 Character ids (numeric, comma separated)
76 </label>
77 <input
78 style={{ display: 'inline-block' }}
79 placeholder="ids"
80 onInput={(event) => {
81 const parsedIds = event.currentTarget.value
82 .split(',')
83 .map((id) => id.trim())
84
85 if (parsedIds.every((id) => /^\d+$/.test(id))) {
86 setIds(parsedIds.map(Number))
87 setError('')
88 } else {
89 setError('Invalid.. only use numbers and comma')
90 }
91 }}
92 />
93 </div>
94
95 <Show when={error()}>
96 <h3 style={{ color: 'red' }}>{error()}</h3>
97 </Show>
98
99 <button
100 type="button"
101 disabled={!!error()}
102 onClick={() => {
103 setIdsToLoad(ids())
104 }}
105 >
106 Load characters
107 </button>
108 <div>
109 <h4 style={{ 'text-align': 'left' }}>Characters:</h4>
110 <Characters ids={idsToLoad()} />
111 </div>
112 </div>
113 )
114}
115
116function Root() {
117 return (

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected