File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
+ import { StyleSheet } from 'react-native' ;
2
3
import { isSvg , isSvgUri } from '../../utils/imageUtils' ;
3
4
import { SvgPackage } from '../../optionalDependencies' ;
4
5
@@ -12,6 +13,7 @@ export interface SvgImageProps {
12
13
*/
13
14
tintColor ?: string | null ;
14
15
data : any ; // TODO: I thought this should be string | React.ReactNode but it doesn't work properly
16
+ style ?: object [ ] ;
15
17
}
16
18
17
19
function SvgImage ( props : SvgImageProps ) {
@@ -28,7 +30,8 @@ function SvgImage(props: SvgImageProps) {
28
30
if ( isSvgUri ( data ) ) {
29
31
return < SvgCssUri { ...others } uri = { data . uri } /> ;
30
32
} else if ( typeof data === 'string' ) {
31
- return < SvgXml xml = { data } { ...others } /> ;
33
+ const flattenStyle = StyleSheet . flatten ( props . style ) as Record < string , any > ;
34
+ return < SvgXml xml = { data } width = { flattenStyle ?. width } height = { flattenStyle ?. height } { ...others } /> ;
32
35
} else if ( data ) {
33
36
const File = data ; // Must be with capital letter
34
37
return < File { ...others } /> ;
You can’t perform that action at this time.
0 commit comments