Skip to content

Commit

Permalink
fix(android): bridgeless mode broken on react-native 0.74 (#1068)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kudo authored Feb 28, 2024
1 parent 5556af6 commit 253126d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
1 change: 1 addition & 0 deletions packages/default-storage/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ android {
buildConfigField "Long", "AsyncStorage_db_size", "${project.ext.AsyncStorageConfig.databaseSizeMB}L"
buildConfigField "boolean", "AsyncStorage_useDedicatedExecutor", "${project.ext.AsyncStorageConfig.useDedicatedExecutor}"
buildConfigField "boolean", "AsyncStorage_useNextStorage", "${useNextStorage}"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", "${isNewArchitectureEnabled}"
}
lintOptions {
abortOnError false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
package com.reactnativecommunity.asyncstorage;

import com.facebook.react.TurboReactPackage;
import com.facebook.react.ViewManagerOnDemandReactPackage;
import com.facebook.react.bridge.ModuleSpec;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
Expand All @@ -17,15 +16,13 @@
import com.facebook.react.module.annotations.ReactModuleList;
import com.facebook.react.module.model.ReactModuleInfo;
import com.facebook.react.module.model.ReactModuleInfoProvider;
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
import com.facebook.react.uimanager.ViewManager;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

@ReactModuleList(
nativeModules = {
Expand Down Expand Up @@ -62,6 +59,7 @@ public ReactModuleInfoProvider getReactModuleInfoProvider() {
@Override
public Map<String, ReactModuleInfo> getReactModuleInfos() {
final Map<String, ReactModuleInfo> reactModuleInfoMap = new HashMap<>();
boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;

Class<? extends NativeModule>[] moduleList =
new Class[] {
Expand All @@ -80,7 +78,7 @@ public Map<String, ReactModuleInfo> getReactModuleInfos() {
reactModule.needsEagerInit(),
reactModule.hasConstants(),
reactModule.isCxxModule(),
TurboModule.class.isAssignableFrom(moduleClass)));
isTurboModule));
}

return reactModuleInfoMap;
Expand All @@ -92,11 +90,6 @@ public Map<String, ReactModuleInfo> getReactModuleInfos() {
}
}

// Deprecated in RN 0.47
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}

@Override
@SuppressWarnings("rawtypes")
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
package com.reactnativecommunity.asyncstorage

import com.facebook.react.TurboReactPackage
import com.facebook.react.ViewManagerOnDemandReactPackage
import com.facebook.react.bridge.ModuleSpec
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.module.annotations.ReactModule
import com.facebook.react.module.annotations.ReactModuleList
import com.facebook.react.module.model.ReactModuleInfo
import com.facebook.react.module.model.ReactModuleInfoProvider
import com.facebook.react.turbomodule.core.interfaces.TurboModule
import com.facebook.react.uimanager.ReactShadowNode
import com.facebook.react.uimanager.ViewManager
import com.reactnativecommunity.asyncstorage.next.StorageModule

@ReactModuleList(
Expand All @@ -32,18 +28,19 @@ class AsyncStoragePackage : TurboReactPackage() {
return reactModuleInfoProviderClass.newInstance() as ReactModuleInfoProvider
} catch (e: ClassNotFoundException) {
return ReactModuleInfoProvider {
val isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
val reactModule: ReactModule = StorageModule::class.java.getAnnotation(
ReactModule::class.java)!!

mutableMapOf(
mapOf(
StorageModule.NAME to ReactModuleInfo(
reactModule.name,
StorageModule::class.java.name,
reactModule.canOverrideExistingModule,
reactModule.needsEagerInit,
reactModule.hasConstants,
reactModule.isCxxModule,
TurboModule::class.java.isAssignableFrom(StorageModule::class.java)
isTurboModule
)
)
}
Expand Down

0 comments on commit 253126d

Please sign in to comment.