Skip to content

Commit 75441bd

Browse files
yedidyakethanshar
authored andcommitted
Handle Image prop source.uri when it is an empty string. (#112)
This causes a warning in react-native: 'Error source.uri should not be an empty string'
1 parent 4e0ad31 commit 75441bd

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/components/image/__tests__/index.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,10 @@ describe('Image', () => {
5959
const uut = new Image({source: {uri: null}});
6060
expect(uut.getImageSource()).toEqual({uri: undefined});
6161
});
62+
63+
it('should handle when source sent with uri is empty string', () => {
64+
const uut = new Image({source: {uri: ''}});
65+
expect(uut.getImageSource()).toEqual({uri: undefined});
66+
});
6267
});
6368
});

src/components/image/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Image extends BaseComponent {
5151
}
5252

5353
const {source} = this.props;
54-
if (_.get(source, 'uri') === null) {
54+
if (_.get(source, 'uri') === null || _.get(source, 'uri') === '') {
5555
return {...source, uri: undefined};
5656
}
5757

0 commit comments

Comments
 (0)