From 028235687810262d0f993853c54dac0d45b2432d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Sverre=20Lien=20Sell=C3=A6g?= Date: Wed, 3 Jun 2020 14:14:14 +0200 Subject: [PATCH] add dependency for useEffect --- src/Events.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Events.js b/src/Events.js index ff80a3a..c4c4970 100644 --- a/src/Events.js +++ b/src/Events.js @@ -115,10 +115,12 @@ export default function Events() { const [events, setEvents] = useState(null) useEffect(async () => { - const res = await fetch(endpoint, fetch_options) - const result = await res.json() - setEvents(result) - }, []) + if (events === null) { + const res = await fetch(endpoint, fetch_options) + const result = await res.json() + setEvents(events) + } + }, [events]) if (events === null) { return

Laster arrangement...