db.transaction only fires once

I currently have a method that runs the first time it’s called. The strange behavior is that it does not execute when I reload the component. It only runs once and other than that it will not run. I get no error message.

  selectDropdownSelection = () => {
    console.log('starting selectDropdownSelection')
    db.transaction(tx => {
      tx.executeSql('select * from dr_report_templates', [], (_, { rows: { _array } }) => {
        console.log('inside executeSql')
        const templateData = _array;
        this.setState({ options: templateData })
      }, (trans, error) => {
        console.error(error);
      }
    );
    },
      error => {
        console(error);
      },
      () => console.log( 'ran selectDropdownSelection')
    );
  }

The first time I initialize this it works. The second times and so on it no longer works. The first time all console logs appear. Second time only first one at top appears. Any ideas why?

Hey @impactcolor,

Could you create a Snack that reproduces this issue? Also, have you tested it on both platforms?

Cheers,
Adam


Here goes the snack. The file in question would be src/screens/OrderDetails.js it appears that when I do one db transaction it wont execute it anymore. I tried it on simulator and also on iphone.

Also I log console.log(db) and I get this:
h {
“_currentTask”: _ {
“errorCallback”: [Function anonymous],
“readOnly”: false,
“successCallback”: [Function anonymous],
“txnCallback”: [Function anonymous],
},
“_db”: n {
“_closed”: false,
“_name”: “db.db”,
},
“_running”: true,
“_txnQueue”: t {
“first”: Object {
“item”: _ {
“errorCallback”: [Function anonymous],
“readOnly”: false,
“successCallback”: [Function anonymous],
“txnCallback”: [Function anonymous],
},
},
“last”: Object {
“item”: _ {
“errorCallback”: [Function anonymous],
“readOnly”: false,
“successCallback”: [Function anonymous],
“txnCallback”: [Function anonymous],
},
},
“length”: 1,
},
“version”: “1.0”,
}

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