Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to convert object to array for FlatList in React Native

I have JSON object taken from Firebase real-time database. What I want is make an array from object and pass this array to state. Hence I want to pass this data to FlatList Component.

This is how my Object looks like:

enter image description here

Actually, I don't need keys, just like this ->

enter image description here

I need your help because I just started to learn JS, before was programming on Android Studio

like image 840
Just Ahead Avatar asked Aug 19 '18 22:08

Just Ahead


1 Answers

You can use Object.values to get an array:

const array = Object.values( obj );
like image 65
devserkan Avatar answered Sep 28 '22 07:09

devserkan