I'm trying to bring rows of data back from an SQLite database and then iterate through them so I can manipulate the data of each row to present them differently (ie, convert a date into a customised format).
Bringing the data back is fine (from the ReadEntries function), which I do in a useEffect so that it only runs once on the screen load, but the duplicating of the array and then updating the rows doesn't seem to work. I think it might have something to do with the fact setting the value of a useState array isn't quick enough to update for my duplicate array to then take a full snapshot of it.
It sometimes works when I save multiple times in VS Code, presumably because the state is already stored for subsequent screen refreshes.
useEffect(() => {
    var results: SQLite.ResultSetRowList;   
    const response = async (): Promise<any> => {
      await ReadEntries(projectID).then((value) => {
        results = value as SQLite.ResultSetRowList;
        setEntries(results.raw); //this works
        let newEntries = [...entries];      
        for (let i = 0; i < newEntries.length; i++) {
          let newStartDate = new Date(newEntries[i].startDate);
          newEntries[i].dateOfEntry = newEntries[i].dateOfEntry;
          newEntries[i].startDate =
            newStartDate.getDate().toString() +
            "/" +
            newStartDate.getMonth().toString() +
            "/" +
            newStartDate.getFullYear().toString();
        }
       setEntries(newEntries);
      });
    };
    response().catch((error) => {
      "ERROR: " + error;
    });
  }, []);
Thanks