Closed hvardhan617 closed 5 years ago
There are two ways you can do this:
recognition
. You can set these to your callback function when constructing or mounting your component:
const { recognition } = this.props
recognition.onend = () => console.log("Listening has stopped");
recognition.onstart = () => console.log("Listening has started");
listening
property, which is another property injected by react-speech-recognition
. If you're using a class-based React component, you can pick up these changes in the componentWillReceiveProps
lifecycle hook. For example:
componentWillReceiveProps(nextProps) {
if (this.props.listening !== nextProps.listening) {
console.log(nextProps.listening);
}
}
Hope that helps!
Will we get any callbacks while invoking async functions such as startListening,stopListening,abortListening ? If so, how can we handle the callbacks?