snapshot.forEach(function(childSnapshot) {
groupRef.child(childSnapshot.key).once("value", (snap) => {
this.setState.bind({
expenses: this.state.expenses.concat(snap.val()),
});
})
})
Run Code Online (Sandbox Code Playgroud)
我得到的错误是
undefined is not an object (evaluating '_this2.setState')
Run Code Online (Sandbox Code Playgroud)
国家已按以下方式宣布
constructor(props) {
super (props);
this.state = {
expenses: [],
};
}
Run Code Online (Sandbox Code Playgroud)