Skip to content
This repository was archived by the owner on Mar 13, 2023. It is now read-only.

Commit 6064db7

Browse files
author
Mohamed K. Coulibali
committed
feat: log warnings when Sovran native module is missing...
...instead of throwing errors
1 parent cd2ba88 commit 6064db7

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

src/index.tsx

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,19 @@ const LINKING_ERROR =
77
'- You rebuilt the app after installing the package\n' +
88
'- You are not using Expo managed workflow\n';
99

10-
const Sovran = NativeModules.Sovran
11-
? NativeModules.Sovran
12-
: new Proxy(
13-
{},
14-
{
15-
get() {
16-
throw new Error(LINKING_ERROR);
17-
},
18-
}
19-
);
10+
const Sovran = NativeModules.Sovran;
11+
if (Sovran) {
12+
const { ON_STORE_ACTION } = Sovran.getConstants();
2013

21-
const { ON_STORE_ACTION } = Sovran.getConstants();
22-
23-
const SovranBridge = new NativeEventEmitter(Sovran);
24-
25-
// Listen to Native events
26-
SovranBridge.addListener(ON_STORE_ACTION, (event) => {
27-
onStoreAction(event.type, event.payload);
28-
});
14+
const SovranBridge = new NativeEventEmitter(Sovran);
2915

16+
// Listen to Native events
17+
SovranBridge.addListener(ON_STORE_ACTION, (event) => {
18+
onStoreAction(event.type, event.payload);
19+
});
20+
} else {
21+
console.warn(LINKING_ERROR);
22+
}
3023
export { createStore, Store, Notify, Unsubscribe } from './store';
3124
export { registerBridgeStore } from './bridge';
3225
export * from './persistor';

0 commit comments

Comments
 (0)