में फायरबेस वादा के साथ सेटस्टेट मैं प्रतिक्रिया घटक के अंदर राज्य कैसे सेट कर सकता हूं?रिएक्ट
यहाँUncaught TypeError: Cannot read property 'setState' of null
घटक कोड सूची है:
class MessageList extends React.Component {
constructor(props){
super(props);
this.state = {
messages: []
};
var firebaseRef = firebase.database().ref();
firebaseRef.once('value')
.then(function(dataSnapshot) {
this.setState({
messages: messages
});
});
}
render() { ... }
}
मुझे माफ करना, @ बेंजामिन gruenbaum, लेकिन मेरा मतलब मैं क्यों सके firebase से डेटा प्राप्त है, और "इस" नहीं के बारे में कुंजी शब्द –
आपकी बग 'इस 'कीवर्ड की वजह से है। मैं इसे अपूर्ण या डुप्लिकेट के रूप में बंद कर सकता हूं - आपके लिए और भविष्य के आगंतुकों के लिए मुझे लगता है कि इसे डुप्लिकेट के रूप में बंद करना बेहतर है। –