【问题标题】:"InvalidStateError: DOM Exception 11: This transaction is already finalized."“InvalidStateError:DOM 异常 11:此事务已完成。”
【发布时间】:2020-05-04 08:01:36
【问题描述】:

我经历了很多问题可能是它的重复问题。:(

我得到了异常 -**“消息”:

"InvalidStateError: DOM Exception 11: 这个事务已经 敲定。事务在成功或失败后提交 处理程序被调用。如果你使用 Promise 来处理回调, 请注意,遵循 A+ 标准的实现遵循 运行到完成语义,因此 Promise 解决发生在 随后的滴答声,因此在事务提交之后。"**

在 React 本机 android 应用程序中,我从离线数据中获取值以进行约会。我已经完成了延迟加载。我的预约限制是 10 人。

我有一个平面列表,我正在检查平面列表 onEndReached 属性。

在 onEndReached 属性中,我正在从本地数据库中获取值,这是我获取离线约会值的函数

  GetAllAppointment(data) {
    console.log("DATA IN -------->>", data);
    return new Promise((resolve, reject) => {
      this.initDB().then((db) => {
        db.transaction((tx) => {

          getObj('skipRecord', (id) => {

           var skipRecord = ((data.pageNumber - 1) * 10);

            let userAppointmentList = [];
            tx.executeSql("Select * from ios_Appointment where date >= " + nowDate + " and clinicianId =" + data.UserID + " and  fName Like '%" + data.searchKey + "%' OR lName Like '%" + data.searchKey + "%' OR address Like '%" + data.searchKey + "%' ORDER BY (date)").then(([tx, results]) => {
              if (results.rows.length > 0) {
                for (let i = skipRecord; i < results.rows.length; ++i) {
                  userAppointmentList.push(results.rows.item(i));
                }
              }
              let pages;
              pages = results.rows.length / records;
              pages = Math.ceil(pages)
              let items = {
                "Version": "1.2.3",
                "StatusCode": 200,
                "Message": "Success",
                "Result": userAppointmentList,
                "pagesCount": pages
              }

              resolve(results);

            }).then((result) => {
              // this.closeDatabase(db);
            }).catch((err) => {
              console.log("GetAllAppointment 1---->>", err);
            });
          }).catch((err) => {
            console.log("GetAllAppointment 2---->>", err);
          });
        }).catch((err) => {
        });
      }

我将上述函数调用到仪表板页面,我将在其中将此返回预约添加到 Flalist

const db = new Database();
export default class DashboardPage extends Component {
this.page = 1;
.
.
.
handleLoadMore = () => { 
       if (!this.state.showLoader && (this.state.pageCount > this.page)) {
         console.log("handleLoadMore page if------------------>>> ", this.state.showLoader);
         this.page = this.page + 1;
         this.setState({ showBottomLoader: true });
         this.getData(page);
      }
.
.
.
 getData(body) {

              let body = {
                  "pageNumber": page,
                  "searchKey": this.state.searchText,
                  "UserID": 1,
                  "currentDate": new Date().getTime()
               }


      db.GetAllAppointment(body).then((item) => {
         let newData;
         if (item) {
            if (body.pageNumber == 1) {
               newData = item.Result;
               this.state.appointmentList.concat(item.Result)
            } else {
               newData = this.state.appointmentList.concat(item.Result)
            }


            this.setState({
               showLoader: false,
               appointmentList: newData,
               pageCount: item.pagesCount,
               showBottomLoader: false,
               isRefreshing: false
            })
         }
      }).catch((err) => {
         this.setState({
            showLoader: false,
            appointmentList: newData,
            pageCount: item.pagesCount,
            showBottomLoader: false,
            isRefreshing: false
         })
      })

第一次我得到 10 条记录,但后来我得到 DOM 异常如何解决这个问题:( 在此先感谢

【问题讨论】:

  • 任何想法:(为什么会出现这个异常以及如何在 GetAllAppointment 方法中捕获这个异常???

标签: react-native ecmascript-6 promise es6-promise


【解决方案1】:

终于解决了。

 GetAllAppointment(data) {
    console.log("DATA IN -------->>", data);
    return new Promise((resolve, reject) => {
      this.initDB().then((db) => {
        getObj('skipRecord', (id) => {
        db.transaction((tx) => {


在交易之前,我正在检查本地存储的跳过记录值,然后在执行 db.transaction 时执行 db.transaction 现在终于停止获取 DOM 异常 :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-20
    • 1970-01-01
    • 1970-01-01
    • 2018-08-13
    • 2013-04-28
    • 1970-01-01
    • 2014-11-17
    • 2019-07-11
    相关资源
    最近更新 更多