MCPcopy Create free account
hub / github.com/Klerith/react-hooks / MultipleCustomHooks

Function MultipleCustomHooks

src/03-examples/MultipleCustomHooks.jsx:7–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5
6
7export const MultipleCustomHooks = () => {
8
9 const { counter, increment } = useCounter(1);
10 const { data, isLoading, hasError } = useFetch(`https://www.breakingbadapi.com/api/quotes/${ counter }`);
11 const { author, quote } = !!data && data[0];
12
13 return (
14 <>
15 <h1>BreakingBad Quotes</h1>
16 <hr />
17
18 {
19 isLoading
20 ? <LoadingQuote />
21 : <Quote author={ author } quote={ quote } />
22 }
23
24 <button
25 className="btn btn-primary"
26 disabled={ isLoading }
27 onClick={ () => increment() }>
28 Next quote
29 </button>
30
31 </>
32 )
33}

Callers

nothing calls this directly

Calls 3

useCounterFunction · 0.90
useFetchFunction · 0.90
incrementFunction · 0.85

Tested by

no test coverage detected