Skip to content

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

Description

@personapp

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions