Skip to content

Commit 7423a1f

Browse files
committed
Minor Refactor code on develop
1 parent 3211429 commit 7423a1f

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

README.md

+14-3
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,20 @@ setNativeExceptionHandler((errorString) => {
381381
*More Examples can be found in the examples folder*
382382
- Preserving old handler (thanks to zeh)
383383

384-
#### react-native-navigation (Wix)
384+
# Known issues and fixes:
385385

386-
When you use the [wix library](http://wix.github.io/react-native-navigation/) to navigate, you need to add a *false* parameter to _setNativeExceptionHandler_. Otherwise it will recreate the application above the crash screen.
386+
### react-native-navigation (Wix)
387+
388+
This is specifically occuring when you use [wix library](http://wix.github.io/react-native-navigation/) for navigation along with react-native-exception-handler. Whenever an error occurs, it will recreate the application above the crash screen.
389+
390+
391+
**Fix:**
392+
393+
You need to set second parametera as *false* while calling _setNativeExceptionHandler_.
394+
The second parameter is an android specific field which stands for forceQuitOnError.
395+
When set to false it doesnt quit the app forcefully on error. In short :
396+
397+
Credit goes to **Gustavo Fão Valvassori**
387398

388399
```js
389400
setNativeExceptionHandler(nativeErrorCallback, false);
@@ -396,7 +407,7 @@ setNativeExceptionHandler(nativeErrorCallback, false);
396407
- [Fred Chasen](https://github.com/fchasen)
397408
- [Christoph Jerolimov](https://github.com/jerolimov)
398409
- [Peter Chow](https://github.com/peteroid)
399-
410+
- [Gustavo Fão Valvassori](https://github.com/faogustavo)
400411
## TESTING NATIVE EXCEPTIONS/ERRORS
401412

402413
To make sure this module works. You can generate a native exception using the module `rn-test-exception-handler`.

android/src/main/java/com/masteratul/exceptionhandler/ReactNativeExceptionHandlerModule.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ public class ReactNativeExceptionHandlerModule extends ReactContextBaseJavaModul
1414
private ReactApplicationContext reactContext;
1515
private Activity activity;
1616
private static Class errorIntentTargetClass = DefaultErrorScreen.class;
17-
private boolean forceToQuit;
1817
private Callback callbackHolder;
1918

2019
public ReactNativeExceptionHandlerModule(ReactApplicationContext reactContext) {
@@ -29,10 +28,9 @@ public String getName() {
2928

3029

3130
@ReactMethod
32-
public void setHandlerforNativeException(final boolean forceToQuit, Callback customHandler){
31+
public void setHandlerforNativeException(Callback customHandler, final boolean forceToQuit){
3332
this.callbackHolder = customHandler;
34-
this.forceToQuit = forceToQuit;
35-
33+
3634
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
3735
@Override
3836
public void uncaughtException(Thread thread, Throwable throwable) {
@@ -52,8 +50,9 @@ public void uncaughtException(Thread thread, Throwable throwable) {
5250
activity.startActivity(i);
5351
activity.finish();
5452

55-
if (forceToQuit)
53+
if (forceToQuit) {
5654
System.exit(0);
55+
}
5756
}
5857
});
5958
}

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const setNativeExceptionHandler = (customErrorHandler = noop, forceApplic
2525
if (Platform.OS === 'ios') {
2626
ReactNativeExceptionHandler.setHandlerforNativeException(customErrorHandler);
2727
} else {
28-
ReactNativeExceptionHandler.setHandlerforNativeException(forceApplicationToQuit, customErrorHandler);
28+
ReactNativeExceptionHandler.setHandlerforNativeException(customErrorHandler, forceApplicationToQuit);
2929
}
3030
};
3131

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-exception-handler",
3-
"version": "2.4.0",
3+
"version": "2.4.1",
44
"description": "A react native module that lets you to register a global error handler that can capture fatal/non fatal uncaught exceptions.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)