'ReactJs displaying objects passed in as props
I'm trying to pass an Object as props to a child component but when I log the data being passed it returns the following:graphs:"[object Object]"
Here is part of the code:
const test = {
'data': [ 'data',{
id: value.id,
graph_title: value.graph_title,
graph_metric1:value.graph_metric1,
graph_metric2:value.graph_metric2,
graph_type:value.graph_type,
graph_category:value.graph_category
}]
};
<Draggable className="drag-element" type="graphs" data={test}>TESTING</Draggable>
Solution 1:[1]
There isn't actually anything wrong with how the object is displayed, as that is the correct Javascript behavior. If you want to print out the actual data within the object, you'll have to access it like such:
console.log(data.data.id)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
