Skip to content

Commit 558cd6c

Browse files
committed
change isLoading to setLoading
1 parent a9acc67 commit 558cd6c

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

02-tours/setup/src/App.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ import Tours from "./Tours";
66
const url = "https://course-api.com/react-tours-project";
77
function App() {
88
const [tours, setTours] = useState([]);
9-
const [loading, isLoading] = useState(true);
9+
const [loading, setLoading] = useState(true);
1010

1111
const getTours = async () => {
12-
isLoading(true);
13-
const response = await fetch(url);
14-
const tours = await response.json();
15-
isLoading(false);
16-
setTours(tours);
12+
try {
13+
const response = await fetch(url);
14+
const tours = await response.json();
15+
setLoading(false);
16+
setTours(tours);
17+
} catch (error) {
18+
setLoading(false);
19+
console.log(error);
20+
}
1721
};
1822

1923
useEffect(() => {

0 commit comments

Comments
 (0)