मैं एक मानचित्र घटक और टूलबार के बीच संवाद करने के लिए एक ईवेंट एमिटर का उपयोग कर रहा हूं। नोट * मैं बिना किसी मुद्दे के अपने ऐप के अन्य हिस्सों में इस कोड का उपयोग कर रहा हूं। मुझे जो त्रुटि मिल रही है वह है:एक प्रतिक्रिया देशी को हल करने के लिए कैसे करें EventEmitterListener चेतावनी
चेतावनी: सेटस्टेट (...): केवल एक घुड़सवार या बढ़ते घटक को अपडेट कर सकता है। इसका आमतौर पर मतलब है कि आपने एक अनमाउंट घटक पर setState() कहा जाता है। यह एक नो-ऑप है। अपरिभाषित घटक के लिए कोड की जांच करें।
मैंने इसी तरह की पोस्टों से इसे हल करने का प्रयास किया है लेकिन यह काम नहीं कर रहा है। मैंने सोचा कि इसे & & दोनों घटकों में माउंट माउंट के साथ करना था?
टूलबार घटक
componentDidMount() {
this.showLocateIconListener = AppEventEmitter.addListener('isTrip', this.isTrip.bind(this));
this.endTripListener = AppEventEmitter.addListener('showLocateIcon', this.showLocateIcon.bind(this));
this.endSubdivisionIcon = AppEventEmitter.addListener('showSubdivisionIcon', this.showSubdivisionIcon.bind(this));
}
componentWillUnMount() {
this.showLocateIconListener.remove();
this.endTripListener.remove();
this.endSubdivisionIcon.remove();
}
//// this is where the error is happening
showSubdivisionIcon(val) {
if (val != 0)
this.setState({
items: menuSubdivision,
subdivisionId: val
})
else
this.setState({
items: menu
})
}
नक्शा घटक
onMarkerPress(val) {
AppEventEmitter.emit('showSubdivisionIcon', val.id);
}
EventEmitter.js के लिए कंसोल त्रुटि विवरण इस
subscription.listener.apply(
subscription.context,
Array.prototype.slice.call(arguments, 1)
);
EventEmitter.js में पूरा अनुभाग की ओर जाता है