Last active
July 19, 2022 20:54
-
-
Save hurali97/78116fa2fa7549ea5a384452b37c2c02 to your computer and use it in GitHub Desktop.
Updated getPackages method for MainApplicationReactNativeHost
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.facebook.react.TurboReactPackage; | |
import com.facebook.react.bridge.NativeModule; | |
import com.facebook.react.module.model.ReactModuleInfoProvider; | |
import com.facebook.react.module.model.ReactModuleInfo; | |
import java.util.HashMap; | |
import java.util.Map; | |
import com.rearchdemo.custommodules.Dlog; | |
import androidx.annotation.Nullable; | |
@Override | |
protected List<ReactPackage> getPackages() { | |
List<ReactPackage> packages = new PackageList(this).getPackages(); | |
// Packages that cannot be autolinked yet can be added manually here, for example: | |
// packages.add(new MyReactNativePackage()); | |
// TurboModules must also be loaded here providing a valid TurboReactPackage implementation: | |
// packages.add(new TurboReactPackage() { ... }); | |
packages.add(new TurboReactPackage() { | |
@Nullable | |
@Override | |
public NativeModule getModule(String name, ReactApplicationContext reactContext) { | |
if (name.equals(Dlog.NAME)) { | |
return new Dlog(reactContext); | |
} else { | |
return null; | |
} | |
} | |
@Override | |
public ReactModuleInfoProvider getReactModuleInfoProvider() { | |
return () -> { | |
final Map<String, ReactModuleInfo> moduleInfos = new HashMap(); | |
moduleInfos.put( | |
Dlog.NAME, | |
new ReactModuleInfo( | |
Dlog.NAME, | |
"Dlog", | |
false, // canOverrideExistingModule | |
false, // needsEagerInit | |
true, // hasConstants | |
false, // isCxxModule | |
true // isTurboModule | |
) | |
); | |
return moduleInfos; | |
}; | |
} | |
}); | |
// If you have custom Fabric Components, their ViewManagers should also be loaded here | |
// inside a ReactPackage. | |
return packages; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment