I am using React. I have an object (that I get from my props) which I was having trouble accessing its key/values. Then I decided to console.log this object alongside a dummy object that mimics the structure of the first object just for comparison reasons, as can be seen by the code below:
var dummyArr1 = [{1:"hey"}, {2:"my"}, {3:"gosh"}]
var dummyArr2 = [{1:"hey"}, {2:"my"}, {3:"gosh"}]
var dummyObj = { key1: dummyArr1, key2gwegwegwegweg: dummyArr2 }
console.log(this.props.foreignObjects)
console.log(dummyObj)
console.log(Object.keys(this.props.foreignObjects))
The result can be seen below:
You can see that the console doesn't immediately show the keys of my original object, only when I click the small arrow on the side to show more. This doesn't happen with my dummy object.
My question is: why is this? Why can't I access my original object's keys (such as by entering this.props.foreignObjects[conexao_inversor])? And how can I access the data inside it?
EDIT: This is the data flow of the app:
First, I get all tables that are foreign keys of the main table:
let foreignKeys = {}
foreignColumns.forEach((column, index) => {
let foreignUrl = "http://localhost:4000/edit/get-data/" + column.foreignKeyOf
fetch(foreignUrl)
.then(foreignResponse => foreignResponse.json())
.then(foreignResponse => {
foreignObjects[column.foreignKeyOf] = foreignResponse.data
})
})
this.setState({
foreignObjects: foreignObjects
})
Then, when invoking my component, I pass props like this:
<TableRowGenerator
tableStructure={this.props.tableStructure}
objects={this.state.objects}
foreignObjects={this.state.foreignObjects}
/>
And then, inside my component, during the render function, I access it like described in the very first snippet of code from my question.