(props: { ids: Array<number> })
| 19 | }) |
| 20 | |
| 21 | function 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 | |
| 65 | function App() { |
| 66 | const [ids, setIds] = createSignal<Array<number>>([]) |
nothing calls this directly
no test coverage detected