Browse Source

add dependency for useEffect

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

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

Loading…
Cancel
Save