diff --git a/src/index.js b/src/index.js index ea2187e..5309fe7 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,4 @@ -import React, { forwardRef } from 'react' +import React, { forwardRef, memo } from 'react' import PropTypes from 'prop-types' import { View, @@ -11,59 +11,61 @@ import { const FastImageViewNativeModule = NativeModules.FastImageView -const FastImage = forwardRef( - ( - { - source, - onLoadStart, - onProgress, - onLoad, - onError, - onLoadEnd, - style, - children, - fallback, - ...props - }, - ref, - ) => { - const resolvedSource = Image.resolveAssetSource(source) - - if (fallback) { - return ( - - - {children} - - ) - } +function FastImageBase({ + source, + onLoadStart, + onProgress, + onLoad, + onError, + onLoadEnd, + style, + children, + fallback, + forwardedRef, + ...props +}) { + const resolvedSource = Image.resolveAssetSource(source) + if (fallback) { return ( - - + {children} ) - }, -) + } + + return ( + + + {children} + + ) +} + +const FastImageMemo = memo(FastImageBase) + +const FastImage = forwardRef((props, ref) => ( + +)) FastImage.displayName = 'FastImage'