Strictly speaking, ecmascript-2017 is the answer, but it can be easily reinforced in earlier versions of Javascript.
You want to use Object.values or Object.entries to view all the properties of an object. Where Object.keys gives you keys, Object.values gives you properties (well, duh) and Object.entries gives you an array of [key, value] for each entry in the object.
You are not using the key in your current code, so here Object.values :
Object.values(this.props.phones).map((type) => { console.log(type) return ( <p>Type of phone: {type}</p> ) })
and here is the parameter Object.entries if you want to use both:
Object.entries(this.props.phones).map(([make, type]) => { console.log(make) console.log(type) return ( <p>Make of phone: {make}</p> <p>Type of phone: {type}</p> ) })
You will see that we are using ES6 destructuring to get two values ββfrom the array that we get from Object.entries .
Gaskets are linked on MDN pages for each function.
source share