import { useEffect } from 'react'; import { getActiveEvents } from '../api'; import EventStream from '../EventStream'; import { IEvent } from '../types'; import useImmutable from '../useImmutable'; export default function ActiveEvents() { const [events, setEvents] = useImmutable([]); const hasEvents = events.length > 0; useEffect(() => { if (!hasEvents) { getActiveEvents().then(setEvents).catch(console.error); // TODO error handling } }, [hasEvents, setEvents]); return (

Events

); }