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

fix: android crash at imagePolyfill #48

Merged
merged 1 commit into from
Apr 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;