Skip to content

Commit 685b12c

Browse files
Fix examples infinite loop
1 parent 22752ff commit 685b12c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

example/src/App.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ const Wrapper = styled.main`
1616
const App = () => {
1717
const [places, setPlaces] = useState([])
1818

19-
useEffect(() => {
19+
const fetchPlaces = async () => {
2020
fetch('places.json')
21-
.then((response) => response.json())
22-
.then((data) => setPlaces(data.results))
23-
})
21+
.then((response) => response.json())
22+
.then((data) => setPlaces(data.results))
23+
}
24+
25+
useEffect(() => {
26+
fetchPlaces();
27+
}, [])
2428

2529
if (!places || places.length === 0) {
2630
return null;

0 commit comments

Comments
 (0)