I am recieving an object from a websocket,
const client = new
W3CWebSocket("ws://ABCD:9080/user");
I want to access values from the object and display it on the browser.
const [object, setObject] = useState("");
client.onopen = () => {
console.log("Connected");
};
client.onmessage = (e) => {
const newObj = JSON.parse(e.data);
Next I want to set new state with the object I recieved.
setObject(newObj.data);
Next, I want to map through that object and access the values inside it:
return (
<div className="App">
<Navbar />
{Object.keys(object).map((objKey, index) => (
<div key={index}>
<p> {objKey} : {object[objKey]}</p>
</div>
))}
<DataTable object = { object } />
</div>
);
How do I map through the object and display the values I need on the browser. I think I'm missing something since nothing is getting displayed n my browser.