1、 发送事件
import { View, DeviceEventEmitter } from 'react-native';const eventEmitter = (status) => {DeviceEventEmitter.emit('eventDemo', { param: status });
}
2、接收订阅事件
useEffect(() => {const eventListener = DeviceEventEmitter.addListener('eventDemo', eventCallback);return () => {eventListener.remove();};}, []);const eventCallback = (event) => {console.log(userStore.userInfo.id, '用户信息');console.log(event.param, '输出:"Hello Hooks!');};