Skip to content

Commit e9de821

Browse files
committed
NormalisedSource is added to fix FastImage's source bug
1 parent 74357f2 commit e9de821

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

example/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
1111
},
1212
"dependencies": {
13+
"@freakycoder/react-native-progressive-fast-image": "^0.1.0",
1314
"react": "16.13.1",
1415
"react-native": "0.63.2",
1516
"react-native-fast-image": "^8.3.2"

lib/ProgressiveFastImage.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ class ProgressiveImage extends React.Component<IProps, IState> {
3838
}).start();
3939
};
4040

41+
// ? Fixing FastImage library's `source` null bug
42+
normalisedSource = () => {
43+
const { source } = this.props;
44+
const normalisedSource =
45+
source && typeof source.uri === "string" && !source.uri.split("http")[1]
46+
? null
47+
: source;
48+
return this.props.source && this.props.source.uri
49+
? normalisedSource
50+
: source;
51+
};
52+
4153
render() {
4254
const { thumbnailSource, source, style, ...props } = this.props;
4355

@@ -52,7 +64,7 @@ class ProgressiveImage extends React.Component<IProps, IState> {
5264
/>
5365
<AnimatedFastImage
5466
{...props}
55-
source={source}
67+
source={this.normalisedSource()}
5668
onLoad={this.onImageLoad}
5769
style={[styles.imageStyle, { opacity: this.animatedImage }, style]}
5870
/>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@freakycoder/react-native-progressive-fast-image",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Customizable progressive image for React Native with FastImage",
55
"main": "./build/dist/ProgressiveFastImage.js",
66
"repository": "git@github.com:WrathChaos/react-native-progressive-fast-image.git",

0 commit comments

Comments
 (0)