Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Fabric in React Native

I'm using React Native 0.71.x in my project and have react-native-fast-image which does not support the latest Fabric architecture. So I'd like to disable it if possible. How do I go about doing this? I haven't set up anything specifically for fabric so I guess it is enabled by default.

like image 246
Zephyr Avatar asked Oct 27 '25 14:10

Zephyr


1 Answers

Follow what is said in React Native's documentation to enable it, and do the opposite.

Assuming that you're coding an app for Android:

MyApplication.java

public class MyApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost =
    new ReactNativeHost(this) {

      // Remove those lines:
      @Nullable
      @Override
      protected JSIModulePackage getJSIModulePackage() {
        return new JSIModulePackage() {
          @Override
          public List<JSIModuleSpec> getJSIModules(
              final ReactApplicationContext reactApplicationContext,
              final JavaScriptContextHolder jsContext) {
            final List<JSIModuleSpec> specs = new ArrayList<>();
            specs.add(new JSIModuleSpec() {
              @Override
              public JSIModuleType getJSIModuleType() {
                return JSIModuleType.UIManager;
              }

              @Override
              public JSIModuleProvider<UIManager> getJSIModuleProvider() {
                final ComponentFactory componentFactory = new ComponentFactory();
                CoreComponentsRegistry.register(componentFactory);
                final ReactInstanceManager reactInstanceManager = getReactInstanceManager();

                ViewManagerRegistry viewManagerRegistry =
                    new ViewManagerRegistry(
                        reactInstanceManager.getOrCreateViewManagers(
                            reactApplicationContext));

                return new FabricJSIModuleProvider(
                    reactApplicationContext,
                    componentFactory,
                    new EmptyReactNativeConfig(),
                    viewManagerRegistry);
              }
            });
            return specs;
          }
        };
      }
    };
}

gradle.properties

# Set this line to false
newArchEnabled=true
like image 77
MidKnight Avatar answered Oct 30 '25 03:10

MidKnight



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!