Using Objects In React
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
Solution 1:
You have used Object.keys(setObject)
where, setObject
is a function, and will return an empty array []
.
Use Object.keys(object)
instead
return (
<divclassName="App"><Navbar />
{Object.keys(object).map((objKey, index) => (
<divkey={index}><p> {objKey} : {object[objKey]}</p></div>
))}
<DataTableobject = {object } /></div>
);
Solution 2:
You are passing setObject instead of object in Object.keys()
Post a Comment for "Using Objects In React"