Bir harita bileşeni ve araç çubuğu arasında iletişim kurmak için bir olay yayımlayıcısı kullanıyorum. Not * Bu kodu, uygulamamın diğer bölümlerinde sorun olmadan kullanıyorum. Aldığım hata:Yerel bir EventEmitterListener uyarısı nasıl giderilir Uyarı
Uyarı: setState (...): Takılmış veya takılan bir bileşeni yalnızca günceller. Bu genellikle, tekil olmayan bir bileşende setState() öğesini çağırdığınız anlamına gelir. Bu bir no-op. Lütfen tanımlanmamış bileşen için kodu kontrol edin.
Bunu benzer iletilerle çözmeye çalıştım ama çalışmıyor. Her iki bileşene de & & bağlantı kesme yöntemiyle bağlantı kurmak zorunda olduğunu düşündüm?
Çubuğu Bileşen
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
})
}
Harita bileşeni
onMarkerPress(val) {
AppEventEmitter.emit('showSubdivisionIcon', val.id);
}
EventEmitter.js için konsol hata ayrıntı EventEmitter.js bu
subscription.listener.apply(
subscription.context,
Array.prototype.slice.call(arguments, 1)
);
Komple bölümüne açar