Search code examples
react-nativerealm

how to iterate a list in react realm database


I have a list which contains the list of data with many properties. I want to iterate and read a single property in all over the list. I can able to read it by mentioning the position(For ex : list[0]) but I want to read it dynamically. How can I iterate and read it dynamically without mentioning the position?


Solution

  • I do this using a map.

    myRealmData.map((eachRealmItem, index) => {
      // whatever you wanna do...
    });
    

    or using a normal for:

    for (let i = 0; myRealmData.length - 1; i++) {
      let eachRealmItem = myRealmData[i];
    }