Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop #26

Open
dressas opened this issue Jun 3, 2020 · 2 comments
Open

Infinite loop #26

dressas opened this issue Jun 3, 2020 · 2 comments

Comments

@dressas
Copy link

dressas commented Jun 3, 2020

This code causes infinite loop, anything wrong?

`import React, {useState} from 'react';
import { Dimensions, View, Image, Button } from 'react-native';
import ImageCropper from 'react-native-simple-image-cropper';
const window = Dimensions.get('window');
const w = window.width;

const IMAGE = 'https://picsum.photos/id/48/900/500';

const CROP_AREA_WIDTH = w;
const CROP_AREA_HEIGHT = w;

export const ModalSelectSnap: React.FC<{}> = () => {
const [cropperParams, setCropperParams] = useState({});

let setCropperParamsFunction = (params) => {
console.log("setCropperParams..........");
console.log(cropperParams);
setCropperParams({params});
};

return (
  <View style={{flex: 1}}>
    <ImageCropper
      imageUri={IMAGE}
      cropAreaWidth={CROP_AREA_WIDTH}
      cropAreaHeight={CROP_AREA_HEIGHT}
      containerColor="black"
      areaColor="black"
      setCropperParams={setCropperParamsFunction}
    />
  </View>
)

}`

@barrsan
Copy link
Owner

barrsan commented Nov 16, 2020

Hi, @dressas! Sorry for late answer. Example app was updated. Now it is using react-hooks. Maybe it will help to you. https://github.com/barrsan/react-native-simple-image-cropper/blob/master/example/App.js#L60

@eng-naveed
Copy link

Works fine when I place it in App.tsx but getting infinite loop when use it somewhere else in the app, like in other screens or in component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants