Skip to content

Commit aa09e15

Browse files
committed
Changed 48 success
1 parent 21404ed commit aa09e15

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/06-advanced-hooks/48-discriminated-tuples-from-custom-hooks.solution.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import { useEffect, useState } from "react";
77
* even after it's been destructured.
88
*/
99
export type Result<T> =
10-
| ["loading", undefined]
11-
| ["error", Error]
12-
| ["success", T];
10+
| ["loading", undefined?]
11+
| ["success", T]
12+
| ["error", Error];
1313

1414
export const useData = <T,>(url: string): Result<T> => {
15-
const [result, setResult] = useState<Result<T>>(["loading", undefined]);
15+
const [result, setResult] = useState<Result<T>>(["loading"]);
1616

1717
useEffect(() => {
1818
fetch(url)
@@ -26,7 +26,7 @@ export const useData = <T,>(url: string): Result<T> => {
2626

2727
const Component = () => {
2828
const [status, value] = useData<{ title: string }>(
29-
"https://jsonplaceholder.typicode.com/todos/1",
29+
"https://jsonplaceholder.typicode.com/todos/1"
3030
);
3131

3232
if (status === "loading") {

0 commit comments

Comments
 (0)