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) const [events, setEvents] = useState(null)
useEffect(async () => { useEffect(async () => {
const res = await fetch(endpoint, fetch_options) if (events === null) {
const result = await res.json() const res = await fetch(endpoint, fetch_options)
setEvents(result) const result = await res.json()
}, []) setEvents(events)
}
}, [events])
if (events === null) { if (events === null) {
return <p>Laster arrangement...</p> return <p>Laster arrangement...</p>

Loading…
Cancel
Save