MCPcopy Create free account
hub / github.com/devrnt/react-use-wizard / LazyQueryStep

Function LazyQueryStep

playground/modules/wizard/reactQuery/lazyQuery.tsx:27–60  ·  view source on GitHub ↗
({ number })

Source from the content-addressed store, hash-verified

25};
26
27const 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
62export default LazyQueryStep;

Callers

nothing calls this directly

Calls 1

useWizardFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…