vemarav / react-native-avatar-crop

Highly customisable <Crop /> component for React Native < 💅 >
https://www.npmjs.com/package/react-native-avatar-crop
MIT License
54 stars 14 forks source link

Using http url in source uri crashes the app #2

Closed himanshi7046 closed 2 years ago

vemarav commented 2 years ago

can you provide a reproducible code or share uri format

himanshi7046 commented 2 years ago

<Crop source={{ uri: 'http://picsum.photos/200/100' }} width={SCREEN_WIDTH} height={SCREEN_WIDTH} cropArea={{ width: SCREEN_WIDTH / 1.3, height: SCREEN_WIDTH / 1.3 }} onCrop={(cropCallback) => (crop = cropCallback)} />

vemarav commented 2 years ago

hey @himanshi7046,

the issue you are facing is because of http, the following snippet works. make sure you set allow insecure url config in your android manifest.

<Crop
        source={{
          uri: 'https://images.unsplash.com/photo-1627942152443-2c0defc72bb5?ixid=MnwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHwzfHx8ZW58MHx8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60',
        }}
        width={SCREEN_WIDTH}
        height={SCREEN_WIDTH}
        cropArea={{width: SCREEN_WIDTH / 1.3, height: SCREEN_WIDTH / 1.3}}
        onCrop={cropCallback => (crop = cropCallback)}
      />
himanshi7046 commented 2 years ago

Null is not an object( evaluting 'RNImageSize.getSize') error

and added android:usesCleartextTraffic="true" in android manifest

vemarav commented 2 years ago

@himanshi7046 you are using redirected url, it won't work. you need to use the final url.

I got following image url by visiting the url you mentioned and it works. https://i.picsum.photos/id/652/200/100.jpg?hmac=FHOGj_uJexMz6mmMNShTa6x_T5-flvAs--cj5Ip0sTU

himanshi7046 commented 2 years ago

@himanshi7046 you are using redirected url, it won't work. you need to use the final url.

I got following image url by visiting the url you mentioned and it works. https://i.picsum.photos/id/652/200/100.jpg?hmac=FHOGj_uJexMz6mmMNShTa6x_T5-flvAs--cj5Ip0sTU

Still having the same issue can you please check it before reply

vemarav commented 2 years ago

make a reproducible repo, I will check it out

vemarav commented 2 years ago

@himanshi7046 need more info to know why its crashing. without reproducible repo or crash logs I won't be able to help.

are you using npm@7 then check issue #3.

Happy to help resolve your issue. It is fully compatible with remote images.