Browse Source

add dependency for useEffect

master
Jørgen Lien Sellæg 6 years ago
parent
commit
0282356878
  1. 10
      src/Events.js

10
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 <p>Laster arrangement...</p>

Loading…
Cancel
Save