{ NativeModules, NativeEventEmitter } from 'react-native' const { StreamingModule } = NativeModules const eventEmitter = new NativeEventEmitter(StreamingModule) const onStartStreamingPressed = useCallback(async () => { await StreamingModule.startStreaming() }, []) const onStopStreamingPressed = useCallback(async () => { await StreamingModule.stopStreaming() }, []) useEffect(() => { const listener = eventEmitter.addListener( 'onSuccessStream', (event) => { showToast('ストリーミングの開始に成功しました ') }) return () => { listener.remove() } }, [showToast]) useEffect(() => { const listener = eventEmitter.addListener( 'onError', (event) => { showToast('ストリーミングに失敗しました ') }) return () => { listener.remove() } }, [showToast])