diff --git a/src/index.js b/src/index.js index f8e42b628..ea2187e98 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,4 @@ -import React, { Component } from 'react' +import React, { forwardRef } from 'react' import PropTypes from 'prop-types' import { View, @@ -11,15 +11,9 @@ import { const FastImageViewNativeModule = NativeModules.FastImageView -class FastImage extends Component { - setNativeProps(nativeProps) { - this._root.setNativeProps(nativeProps) - } - - captureRef = e => (this._root = e) - - render() { - const { +const FastImage = forwardRef( + ( + { source, onLoadStart, onProgress, @@ -30,16 +24,14 @@ class FastImage extends Component { children, fallback, ...props - } = this.props - + }, + ref, + ) => { const resolvedSource = Image.resolveAssetSource(source) if (fallback) { return ( - + + ) - } -} + }, +) + +FastImage.displayName = 'FastImage' const styles = StyleSheet.create({ imageContainer: {