I'm looking for a way to retrieve data from Firebase Realtime Database and display it in FlatList format. What is the most efficient method for extracting the child value and converting it into a custom object?
For example:
class CustomObject {
constructor(id, name, age) {
this.id = id;
this.name = name;
this.age = age;
}
}
export default new CustomObject();
// In my Screen.js file, here's how I retrieve the data...
useEffect(() => {
reference
.on('value', snapshot => {
let data = [];
snapshot.forEach((child) => {
// Need to convert child.val() into a CustomObject
data.push(child.val());
})
setArr(data);
});
});