【发布时间】:2016-11-03 14:35:56
【问题描述】:
我在我的 reactjs 应用程序中定义了 firebase 如下(对于 firebase v2 的要求是正确的)
var App = React.createClass({
mixins: [ReactFire],
componentWillMount: function () {this.bindAsObject(new Firebase(rootURL + 'items/'), 'items')},
render: function () {return <Header itemStore={this.firebaseRefs.items}/>}});
我将标题类中的道具称为休闲:
module.exports = React.createClass({
getInitialState: function () {
return {text: ''}
},
render: function () {return <button type="button" onClick={this.handleClick}>},
handleClick: function () {this.props.itemStore.push({
text:this.state.text,
done:false
});
this.setState({text:''});
}
});
但我面临Uncaught TypeError: Cannot read property 'push' of undefined的错误
【问题讨论】:
-
看来您在
items中有错字。只需检查一下:componentWillMount: function () {this.bindAsObject(new Firebase(rootURL + 'items/'), 'itmes')}, //itmes 应该是我认为的项目 -
@cubbuk 谢谢,实际上在复制粘贴时输入错误,而不是在项目中:)
标签: reactjs firebase firebase-realtime-database