with-sqlite example fails in web version

  1. expo-cli 4.0.17
    expo-sqlite 8.5.0
    react-native sdk-40.0.1
  2. Android/web


The “with-sqlite” example works fine on Android Expo app. However, web version fails when it tries to access sqlite query results.
First exception is TypeError: Cannot read property 'length' of undefined. But it is not the actual source of issue, just a side effect of undefined variable.

Actually, the issue is in the query result. According to docs (and code applies this knowing) the result is represented as

  rows: {

The _array field then used to be set as items state

  React.useEffect(() => {
    db.transaction(tx => {
        `select * from items where done = ?;`,
        [doneHeading ? 1 : 0],
        (_, { rows: { _array } }) => setItems(_array)
  }, []);

Web version works sligltly differently. The result does not have rows._array property. Instead, rows property represent SQLResultSetRowList object which provides item(i) method to access the actual resultset rows.
Fix in form below works for me.

     let res_array = [];
     for (let i=0; i<result.rows.length; i++){

My question is - why this differs in Web and Android version? Where it should be fixed? If it is possible to fix, of course.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.