I have a server publishing updates with SSE for data displayed in the spreadsheet. Rows are unique by id ( see below ). If a new event arrives the event is pushed to the data array and is displayed correctly in the spreadsheet. When an update arrives for an event with existing ID updating the event in the data array does not trigger the spreadsheet to show the update. Please provide guidance. Thank you
I have the following code:
const [data, setData] = useState([]);
const update = (event: any) => {
console.log("received event: ", event);
const index = data.findIndex((el) => el.id === event.id);
if(index !== -1 ) {
data[index] = event;
}
else
data.push(event);
setData([...data]);
};
const eventSource = new EventSource("http://localhost:8080/api/consume");
eventSource.onmessage = e => updateMarkets(JSON.parse(e.data));<SpreadsheetComponent ref={sheetRef}>
<SheetsDirective>
<SheetDirective name='Test'>
<RangesDirective>
<RangeDirective dataSource={data} showFieldAsHeader={false} startCell='A1'/>
</RangesDirective>
</SheetDirective>
</SheetsDirective>
</SpreadsheetComponent>