How To Re Render Table Component Upon Receiving A Notification From Web Socket In React Js?
Im using React table and loading a page which displays a table with data fetched from an API. Im also listening on a web socket and right now, whenever something is sent over a web
Solution 1:
You can simple setState
within onmessage
this.websocket.onmessage = (event) => {
let data = [];
const status = data.status;
if (status === 'failed') {
console.log('Error message received');
// And do nothing, or empty table
} else {
data = JSON.parse(event.data);
}
this.setState({ tableData: data });
};
Post a Comment for "How To Re Render Table Component Upon Receiving A Notification From Web Socket In React Js?"