({ number })
| 25 | }; |
| 26 | |
| 27 | const LazyQueryStep: React.FC<Props> = ({ number }) => { |
| 28 | const { handleStep, isLoading } = useWizard(); |
| 29 | const { error, data, mutateAsync } = useMutation( |
| 30 | `getTodosLazy${number}`, |
| 31 | () => |
| 32 | fetch('https://jsonplaceholder.typicode.com/todos').then((res) => |
| 33 | res.json(), |
| 34 | ), |
| 35 | ); |
| 36 | |
| 37 | handleStep(() => { |
| 38 | return mutateAsync(); |
| 39 | }); |
| 40 | |
| 41 | const content = React.useMemo(() => { |
| 42 | if (error) return 'An error has occurred: ' + (error as Error).message; |
| 43 | |
| 44 | return data |
| 45 | ? data.map((todo) => ( |
| 46 | <div key={todo.id}> |
| 47 | <h1>{data.name}</h1> |
| 48 | </div> |
| 49 | )) |
| 50 | : !isLoading && <p>Click next button to make request</p>; |
| 51 | }, [error, data, isLoading]); |
| 52 | |
| 53 | return ( |
| 54 | <Container> |
| 55 | <P>Step {number}</P> |
| 56 | {content} |
| 57 | {isLoading && <P>Loading...</P>} |
| 58 | </Container> |
| 59 | ); |
| 60 | }; |
| 61 | |
| 62 | export default LazyQueryStep; |
nothing calls this directly
no test coverage detected
searching dependent graphs…