diff --git a/backend/server.js b/backend/server.js index a54f67d..563f136 100644 --- a/backend/server.js +++ b/backend/server.js @@ -57,7 +57,8 @@ async function run() { const stringFormat = JSON.stringify(document); eventArray = [stringFormat, ...eventArray]; }) - response.write(`event: events, data: [${[...eventArray]}]\n\n`) + response.write(`event: events \n`) + response.write(`data: [${[...eventArray]}]\n\n`) changeStream.on("change", data => { diff --git a/frontend/src/components/app/App.js b/frontend/src/components/app/App.js index 262b070..11d4c95 100644 --- a/frontend/src/components/app/App.js +++ b/frontend/src/components/app/App.js @@ -3,7 +3,7 @@ import { useSSE, SSEProvider, createCustomSource } from 'react-hooks-sse'; import './App.css'; import EventList from '../eventList/EventList.js'; -function SSE() { +const SSE = () => { const state = useSSE('events'); const [events, setEvents] = useState([]); // initialises Event state