【发布时间】:2017-02-19 19:33:32
【问题描述】:
有人能解释一下为什么这段代码有效吗:
this.firebaseRef.on('value', (snapshot) => {//...});
这不是:
const foo = this.firebaseRef.on;
foo('value', (snapshot) => {//...});
?
在 react-native devtools 调试器中会抛出错误:Cannot read property 'Y' of undefined
这很有趣,因为当我设置断点并检查它时
foo === this.firebaseRef.on
它给了我真实的感觉。 typeof foo 是一个函数。我不明白。 once 也是如此。
【问题讨论】:
标签: javascript firebase react-native firebase-realtime-database