0

我正在为我的语音转文本应用程序使用react-native-voice/voice 。voice search仅适用于初始屏幕,不适用于任何其他屏幕。下面是我实现的代码。请问有什么线索吗?

class BuyerContainer extends Component {
  constructor(props) {
    super(props);
     // Binding the listeners
     Voice.onSpeechError = this.onSpeechError.bind(this);
     Voice.onSpeechResults = this.onSpeechResults.bind(this);
   }
   // Called when I navigate to other screen
   // Used this because componentWillUnmount does not work for stack navigator
   onNavigation = async routeName => {
    await Voice.destroy().then(Voice.removeAllListeners);
    this.props.navigation.navigate(routeName);
  };
 }
}

我为所有屏幕应用了相同的代码结构。

4

0 回答 0