Skip to content

Commit

Permalink
Fix test for using local image.
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanVann committed Apr 20, 2018
1 parent d87e693 commit 78a28cd
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSou

const FastImageViewNativeModule = NativeModules.FastImageView

const useLocalImage = source => {
// No source.
if (!source) return true
// No uri.
if (!source.uri) return true
// Is a local Android image.
if (source.uri.startsWith('file://')) return true
// We have a remote source.
return false
}

class FastImage extends Component {
setNativeProps(nativeProps) {
this._root.setNativeProps(nativeProps)
Expand All @@ -33,11 +44,7 @@ class FastImage extends Component {
} = this.props

// If there's no source or source uri just fallback to Image.
const noSource = !source
const noURI = !source.uri
const isLocalAndroidImage =
source && source.uri && source.uri.startsWith('file://')
if (noSource || noURI || isLocalAndroidImage) {
if (useLocalImage(source)) {
return (
<Image
ref={e => (this._root = e)}
Expand Down

0 comments on commit 78a28cd

Please sign in to comment.