Skip to content

Commit bd6cc36

Browse files
committed
fix: Ensure compatibility with new React Native version
1 parent 394bbb8 commit bd6cc36

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

android/src/main/java/in/juspay/hypersdkreact/HyperSdkReactModule.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,15 @@ public View createReactSurfaceView(String viewName) {
324324
private View createMerchantView(String viewName) {
325325

326326
if (!useNewApprochForMerchantView) {
327+
if (reactInstanceManager == null) {
328+
reactInstanceManager = this.app.getReactNativeHost().getReactInstanceManager();
329+
}
327330
if (newArchEnabled) {
328331
return createReactSurfaceView(viewName);
329332
}
333+
if (reactInstanceManager == null) {
334+
return null;
335+
}
330336
ReactRootView reactRootView = new ReactRootView(activity);
331337
reactRootView.startReactApplication(reactInstanceManager, viewName);
332338
return reactRootView;
@@ -362,7 +368,7 @@ private View createMerchantView(String viewName) {
362368
@Override
363369
public View getMerchantView(ViewGroup viewGroup, MerchantViewType merchantViewType) {
364370
Activity activity = (Activity) getCurrentActivity();
365-
if (!useNewApprochForMerchantView && reactInstanceManager == null || activity == null) {
371+
if (activity == null) {
366372
return super.getMerchantView(viewGroup, merchantViewType);
367373
} else {
368374
View merchantView = null;
@@ -426,12 +432,6 @@ private void createHyperService(@Nullable String tenantId, @Nullable String clie
426432
Application app = activity.getApplication();
427433
if (app instanceof ReactApplication) {
428434
this.app = ((ReactApplication) app);
429-
if (!useNewApprochForMerchantView) {
430-
reactInstanceManager = ((ReactApplication) app).getReactNativeHost().getReactInstanceManager();
431-
}
432-
else {
433-
reactInstanceManager = null;
434-
}
435435
}
436436
if (tenantId != null && clientId != null) {
437437
hyperServices = new HyperServices(activity, tenantId, clientId);

0 commit comments

Comments
 (0)