Skip to content

Commit b4d9017

Browse files
authored
Merge pull request #57 from jeffraux/master
Use componentDidUpdate instead of componentWillReceiveProps
2 parents 5d7111c + cc91b75 commit b4d9017

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/ImageView.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,42 +164,42 @@ export default class ImageView extends Component<PropsType, StateType> {
164164
Dimensions.addEventListener('change', this.onChangeDimension);
165165
}
166166

167-
componentWillReceiveProps(nextProps: PropsType) {
167+
componentDidUpdate() {
168168
const {images, imageIndex, isVisible} = this.state;
169169

170170
if (
171-
typeof nextProps.isVisible !== 'undefined' &&
172-
nextProps.isVisible !== isVisible
171+
typeof this.props.isVisible !== 'undefined' &&
172+
this.props.isVisible !== isVisible
173173
) {
174-
this.onNextImagesReceived(nextProps.images, nextProps.imageIndex);
174+
this.onNextImagesReceived(this.props.images, this.props.imageIndex);
175175

176176
if (
177-
images !== nextProps.images ||
178-
imageIndex !== nextProps.imageIndex
177+
images !== this.props.images ||
178+
imageIndex !== this.props.imageIndex
179179
) {
180180
const imagesWithoutSize = getImagesWithoutSize(
181-
addIndexesToImages(nextProps.images)
181+
addIndexesToImages(this.props.images)
182182
);
183183

184184
if (imagesWithoutSize.length) {
185185
Promise.all(fetchImageSize(imagesWithoutSize)).then(
186186
updatedImages =>
187187
this.onNextImagesReceived(
188188
this.setSizeForImages(updatedImages),
189-
nextProps.imageIndex
189+
this.props.imageIndex
190190
)
191191
);
192192
}
193193
}
194194

195195
this.setState({
196-
isVisible: nextProps.isVisible,
196+
isVisible: this.props.isVisible,
197197
isFlatListRerendered: false,
198198
});
199199

200200
this.modalBackgroundOpacity.setValue(0);
201201

202-
if (nextProps.isVisible) {
202+
if (this.props.isVisible) {
203203
Animated.timing(this.modalAnimation, {
204204
duration: 400,
205205
toValue: 1,

0 commit comments

Comments
 (0)