[Solved] How to convert string to array in react js?


I’ve figured out that the JSON is already valid, I was just too confused and irritated by the errors with different usages of Object.keys etc.!

I’ve solved the issue with:

const arr = Object.entries(this.props.user);
const mapped = [];
arr.forEach(([key, value]) => mapped.push(value));

This way I am cutting out the {} entries inside the object and saving them to an array, with which I can map and render the data inside as follows:

..

return(
<div>
 {mapped.map((user)=>
   <div>
     <b>{user.name}</b>

...

1

solved How to convert string to array in react js?