Problem with android library REACT-NATIVE

Asked

Viewed 112 times

0

I’m using a library to crop photos in my project, but it only works for android, when I run the app on android it runs normally, but when it runs on Ios, from the error in importing the library, there’s some way when to run this app on Ios it "forget" that library?

library: https://github.com/zainozzaini/react-native-android-image-cropper

1 answer

0

Use the library Platform

import {Platform} from 'react-native';

// Importe a biblioteca assim:

const ImageCropperPackage = Platform.select({
  ios: () => null,
  android: () => require('com.ozdevcode.theartofdev.edmodo.cropper.ImageCropperPackage'),
})();

// OU

const ImageCropperPackage = Platform.select({
  ios: () => require('br.com.outrabiblioteca.ImageCropperPackage'),
  android: () => require('com.ozdevcode.theartofdev.edmodo.cropper.ImageCropperPackage'),
})();

With this you just use the component only when the constant ImageCropperPackage is different from null

Browser other questions tagged

You are not signed in. Login or sign up in order to post.