我无法获取 Firebase 实时数据库数据,出现异常并且无法理解原因。
"SyntaxError: Unexpected end of input
at App.componentDidMount (blob:http://localhost:8081/debac782-dd29-4750-a1b8-dc8e57c59632:1571:45)
at App.proxiedComponentDidMount (blob:http://localhost:8081/debac782-dd29-4750-a1b8-dc8e57c59632:57980:42)
at commitLifeCycles (blob:http://localhost:8081/debac782-dd29-4750-a1b8-dc8e57c59632:31136:28)
at commitLayoutEffects (blob:http://localhost:8081/debac782-dd29-4750-a1b8-dc8e57c59632:33340:13)
at Object.invokeGuardedCallbackImpl (blob:http://localhost:8081/debac782-dd29-4750-a1b8-dc8e57c59632:20647:16)
at invokeGuardedCallback (blob:http://localhost:8081/debac782-dd29-4750-a1b8-dc8e57c59632:20743:37)
at commitRootImpl (blob:http://localhost:8081/debac782-dd29-4750-a1b8-dc8e57c59632:33172:15)
at unstable_runWithPriority (blob:http://localhost:8081/debac782-dd29-4750-a1b8-dc8e57c59632:55717:18)
at runWithPriority (blob:http://localhost:8081/debac782-dd29-4750-a1b8-dc8e57c59632:24203:16)
at commitRoot (blob:http://localhost:8081/debac782-dd29-4750-a1b8-dc8e57c59632:33041:9)"
在 App.js 构造函数中,我像这样初始化 firebase(工作正常):
if (!firebase.apps.length) {
firebase.initializeApp(config);
}
在 componentDidMount() 中,我试图获取数据库引用:
componentDidMount() {
firebase.database().ref('listings').once("value", snapshot => {
//handle snapshot data
});
}
React Native 的远程调试器似乎在捆绑中导致语法错误。一旦我禁用远程调试,问题就会消失,我可以从 Firebase 数据库中获取数据。
这看起来与Github 问题中描述的相同。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句