I'm very new to Javascript and React, so please excuse if this is a dumb question...I'm calling data from an API that gives me a json made up of a bunch of objects within objects within objects. I'm trying to create a nested menu of all of these objects, but I'm having trouble even rendering each level.
I've tried using Object.keys to turn the first layer of objects' items into an array, but it won't let me return these results (only console.log works) because I get the "Objects are not valid as a React child" error for the objects within. How do I access these 4-5 layer-deep objects without having super messy code?
Please let me know if you want to see more code/the json objects laid out or any screenshots
componentDidMount() {
axios
.get("https://www.ifixit.com/api/2.0/categories")
.then(response => this.setState({ categories: response.data }));
}
listOfCategories returns an array of the first layer of objects
render() {
const { categories } = this.state;
const listOfCategories = Object.keys(categories);
console.log(listOfCategories);
this is the part where I can do console.log(categories[key]) and see the second layer to the last layer of nested objects, but I can't actually return it because of the "Objects are not valid as a React child" error.
const list = listOfCategories.map(key => {
console.log(categories[key]);
//return categories[key];
return null;
});
this part actually renders the first layer of categories to the screen
return (
<div>
{listOfCategories}
</div>
);
}
}
Screenshot of console.log(categories[key]), which shows the data starting from the second layer of objects. The first layer (listOfCategories) is: Apparel {}, Appliance{}, Camera{}, Car and Truck{}, etc.

console.log(categories[key]);look like?categoriesobject(e.g. const category = Object.keys(categories[key]); return category.map(c => c['someProperty']);). Let me know if that's clear!const list...also, because the json data I'm trying to use is 15 objects with each of those having another 8-10 objects, and more objects within those, do you know if there is a way I can recursively call something to just apply it to each level?