mysql - 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...
解决方案
推荐阅读
- java - 获取存款的所有者(JPA 存储库)
- c++ - 在 C++ 类中初始化二维数组
- javascript - JavaScript 通过引用返回
- r - 减去一列中的值并更改另一列
- python - 将文本文件转换为列表列表
- python-3.x - 为什么我的程序没有读取其他变量?
- c++ - 为什么程序会增加 x 和 y 的值,即使它们更大,那么它们应该是?
- python - 如何排除包含常量字符串的正则表达式匹配
- swiftui - ARKit3 和 swiftUI 中的 ARWorldTrackingConfiguration-DetectImages
- javascript - 使用 Python 和 selenium 访问网站时欺骗经过的访问时间