0
我有一個反應本機應用程序。在應用程序中,我使用事件偵聽器來偵聽來自本機模塊的一些操作,這很好。React Native:在頻繁呼叫時警告消息不起作用
當事件偵聽器捕獲事件console.log
輸出時,它會調用另一個函數,它會再次輸出console.log
,這些函數都可以工作。
但是,當該功能還顯示警報時,它會顯示第一次,但如果顯示警報被多次調用,可能不會。
可能是什麼問題?我可以頻繁顯示警報嗎?
這裏是源代碼:
class Details extends Component {
constructor(props){
super(props);
}
componentDidMount(){
DeviceEventEmitter.addListener('tagDetected', (data)=>{
console.log(data.serial)
this.attendBySerial(data.serial)
});
}
attendBySerial(i){
console.log('Attending', i)
Alert.alert(
'NFC Tag Detected',
JSON.stringify(i)
);
}
render(){
return(
///.......
);
}
}