10
10
11
11
'use strict' ;
12
12
13
- const Image = require ( './Image' ) ;
14
- const React = require ( 'react' ) ;
15
- const StyleSheet = require ( '../StyleSheet/StyleSheet' ) ;
16
- const View = require ( '../Components/View/View' ) ;
13
+ import Image from './Image' ;
14
+ import * as React from 'react' ;
15
+ import StyleSheet from '../StyleSheet/StyleSheet' ;
16
+ import flattenStyle from '../StyleSheet/flattenStyle' ;
17
+ import View from '../Components/View/View' ;
18
+ import type { ImageBackgroundProps } from './ImageProps' ;
17
19
18
20
/**
19
21
* Very simple drop-in replacement for <Image> which supports nesting views.
@@ -39,7 +41,7 @@ const View = require('../Components/View/View');
39
41
* AppRegistry.registerComponent('DisplayAnImageBackground', () => DisplayAnImageBackground);
40
42
* ```
41
43
*/
42
- class ImageBackground extends React . Component < $FlowFixMeProps > {
44
+ class ImageBackground extends React . Component < ImageBackgroundProps > {
43
45
setNativeProps ( props : Object ) {
44
46
// Work-around flow
45
47
const viewRef = this . _viewRef ;
@@ -56,7 +58,7 @@ class ImageBackground extends React.Component<$FlowFixMeProps> {
56
58
57
59
render ( ) : React . Node {
58
60
const { children , style, imageStyle, imageRef, ...props } = this . props ;
59
-
61
+ const flattenedStyle = flattenStyle ( style ) ;
60
62
return (
61
63
< View
62
64
accessibilityIgnoresInvertColors = { true }
@@ -74,8 +76,8 @@ class ImageBackground extends React.Component<$FlowFixMeProps> {
74
76
// So, we have to proxy/reapply these styles explicitly for actual <Image> component.
75
77
// This workaround should be removed after implementing proper support of
76
78
// intrinsic content size of the <Image>.
77
- width : style ?. width ,
78
- height : style ?. height ,
79
+ width : flattenedStyle ?. width ,
80
+ height : flattenedStyle ?. height ,
79
81
} ,
80
82
imageStyle ,
81
83
] }
0 commit comments