首页 > 解决方案 > ReactJS/Electron/MYSQL : Query Callback takes ages

问题描述

I'm trying to build a small app. I found some useful ressources which helped me a lot, but when it comes to problem solving, my (still) superficial knowledge hinders me from analyzing the issue correctly.

First of all I'm running a local database via xampp and successfully connected to it based on this article:

I made the function that encapsulates the whole connection/query/disconnection process a method of my React Component and I'm calling it in componentDidMount() like so:

   componentDidMount() {

    let current = this;
    this.hasMounted = true;
    
    this.getClients(function(rows){
        if (current.hasMounted) {
            current.setState({
                clients : rows
            })
        }
    })
}

The cool thing: It's working. The bad thing. It takes 10 seconds to complete this although my table has just 2 rows... Any thoughts on this?

UPDATE: Resumed working on the app today and it worked perfectly... until it didn't. Might have to do with multiple restarting/hot reloading through npm? Strangely though restarting the PC didn't solve this, as I would have expected made the difference to yesterday...

标签: mysqlnode.jsreactjselectron

解决方案


推荐阅读