react-native-transformable-image icon indicating copy to clipboard operation
react-native-transformable-image copied to clipboard

using onViewTransformed callback to setState() in the parent component causes infinite loop

Open personapp opened this issue 7 years ago • 0 comments

I’m new in React Native so not sure if is it a bug or just my misunderstanding but there is an issue for me when I call the onViewTransformed callback like that

import Image from ‘react-native-transformable-image’;

class Parent extends Component {

constructor(props) { super(props); this.transform = this.transform.bind(this); this.state = { scale: 1, translateX: 0, translateY: 0 }; }

handleTransform(data) { this.setState({ scale: data.scale, translateX: data.translateX, translateY: data.translateY }); }

render() { return ( <Image ... onViewTransformed={this.transform} /> ); } }

it goes to an infinite loop. React Native error sheet says that can be because of componentDidUpdate or componentWillUpdate method.

So what am I missing ??

Thanks in advance.

personapp avatar May 10 '18 14:05 personapp