Skip to content

Commit

Permalink
Merge pull request vivaxy#48 from yum650350/fix/android-crash
Browse files Browse the repository at this point in the history
fix: android crash at imagePolyfill
  • Loading branch information
vivaxy authored Apr 4, 2020
2 parents e841bb6 + 21dc084 commit 9a784fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions autoHeightImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
*/
import React, { useEffect, useState } from 'react';
import ImagePolyfill from './imagePolyfill';
import Image from './animatableImage';
import AnimatableImage from './animatableImage';
import PropTypes from 'prop-types';

import { getImageSizeFitWidth } from './cache';
import { NOOP, DEFAULT_HEIGHT } from './helpers';

// remove `resizeMode` props from `Image.propTypes`
const { resizeMode, ...ImagePropTypes } = Image.propTypes;
const { resizeMode, ...ImagePropTypes } = AnimatableImage.propTypes;

function AutoHeightImage(props) {
const { onHeightChange, source, width, style, ...rest } = props;
Expand All @@ -29,7 +29,7 @@ function AutoHeightImage(props) {
const imageStyles = { width, height };

// Since it only makes sense to use polyfill with remote images
const ImageComponent = source.uri ? ImagePolyfill : Image;
const ImageComponent = source.uri ? ImagePolyfill : AnimatableImage;
return (
<ImageComponent source={source} style={[imageStyles, style]} {...rest} />
);
Expand Down
10 changes: 5 additions & 5 deletions imagePolyfill.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect } from 'react';
import { Platform } from 'react-native';
import Image from './animatableImage';
import { Platform, Image } from 'react-native';
import AnimatableImage from './animatableImage';

const isAndroid = () => Platform.OS === 'android';

Expand All @@ -24,10 +24,10 @@ function ImagePolyfill(props) {
}
}, [source, onError]);

return <Image source={source} {...rest} />;
return <AnimatableImage source={source} {...rest} />;
}

ImagePolyfill.propTypes = Image.propTypes;
ImagePolyfill.defaultProps = Image.defaultProps;
ImagePolyfill.propTypes = AnimatableImage.propTypes;
ImagePolyfill.defaultProps = AnimatableImage.defaultProps;

export default ImagePolyfill;

0 comments on commit 9a784fe

Please sign in to comment.