Taking a guess here but it looks like you want to promis-ify the
Voice.onSpeechResults
callback.
Have your MicButton
function return a promise that resolves with the result you want
export const MicButton = () => new Promise((resolve, reject) => {
Voice.start('en-US')
Voice.onSpeechResults = (res) => {
resolve(res.value[0])
}
Voice.onSpeechError = reject
}).finally(() => {
Voice.removeAllListeners() // clean up
})
0
solved Why is a function not awaited as a promise?