Skip to content

Commit 01c6aee

Browse files
M-i-k-e-lethanshar
authored andcommitted
Image - fix Android crash related to changing views while animating (#2171)
1 parent 55faaf6 commit 01c6aee

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/components/image/index.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ export type ImageProps = RNImageProps &
7878
* An imageId that can be used in sourceTransformer logic
7979
*/
8080
imageId?: string;
81+
/**
82+
* Use a container for the Image, this can solve issues on
83+
* Android when animation needs to be performed on the same
84+
* view; i.e. animation related crashes on Android.
85+
*/
86+
useBackgroundContainer?: boolean;
8187
};
8288

8389
type Props = ImageProps & ForwardRefInjectedProps & BaseComponentInjectedProps;
@@ -176,7 +182,7 @@ class Image extends PureComponent<Props, State> {
176182
return <SvgImage data={source} {...others}/>;
177183
};
178184

179-
renderErrorImage = () => {
185+
renderImageWithContainer = () => {
180186
const {style, cover, modifiers} = this.props;
181187
const {margins} = modifiers;
182188

@@ -241,8 +247,9 @@ class Image extends PureComponent<Props, State> {
241247

242248
renderRegularImage() {
243249
const {error} = this.state;
244-
if (error) {
245-
return this.renderErrorImage();
250+
const {useBackgroundContainer} = this.props;
251+
if (error || useBackgroundContainer) {
252+
return this.renderImageWithContainer();
246253
} else {
247254
return this.renderImage(false);
248255
}

0 commit comments

Comments
 (0)