a7ul / react-native-exception-handler

A react native module that lets you to register a global error handler that can capture fatal/non fatal uncaught exceptions.
MIT License
1.58k stars 133 forks source link

Is it possible to restart the application from the modal? #164

Open guybridge opened 2 years ago

guybridge commented 2 years ago

Trying to use in conjunction with react-native-restart however once the app has crashed. None of the buttons work.

setJSExceptionHandler((error, isFatal) => { jsExceptionHandler(error, isFatal) })

function jsExceptionHandler(error, isFatal = true) { const msg = access(error, "message") || Unknown Error: ${JSON.stringify(error, Object.getOwnPropertyNames(error))} if (isFatal) { showExceptionModal(msg) } }

function showExceptionModal(error) { Alert.alert( "Oops...", "It looks like something went wrong and we will need to restart the app.", [ { text: "Restart", onPress: () => { RNRestart.Restart() }, }, { text: "Logout", onPress: () => { AsyncStorage.setItem(REFRESH_TOKEN, "") RNRestart.Restart() }, }, ] ) }