kfiroo / react-native-cached-image

CachedImage component for react-native
MIT License
938 stars 470 forks source link

ImageBackground : remind developer for different RN version #84

Open samuelplaymore opened 6 years ago

samuelplaymore commented 6 years ago

we use RN 0.45, and we got error of undefined component about ImageBackground.

Please handle it, we suggest choose one way in the following.

  1. update README and tell developer use different version, such as 1.3.5 for RN below 0.45
  2. check if ImageBackground is undefined in CacheImage.js, and use Image instead

Thanks :)

kfiroo commented 6 years ago

@samuelplaymore Hey! You are absolutly right, I will update the README to reflect that.

The recomended solution to your issue is to use the renderImage prop of CachedImage to render your own image component. That may be a RN Image or any other image component such as https://github.com/expo/react-native-responsive-image

ghost commented 6 years ago

@kfiroo why not start using semantic versioning and make a major up for when there's breaking changes like this?

kfiroo commented 6 years ago

@kytwb True, I thought the minor version bump was enough but a second look proved me wrong :) Should we publish a new 2.0.0 version for this or wait for the next big change?

exos commented 6 years ago

0.42.0 here

To fix:

Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in. Check the render method of `CachedImage`.

Next return other warning:

Possible Unhandled Promise Rejection (id: 0):
Cannot read property 'getHostNode' of null
TypeError: Cannot read property 'getHostNode' of null

You can do:

                <CachedImage
                    source={{
                        uri: this.props.uri,
                    }}
                    renderImage={(data) => {
                        return (<Image {...data}/>);
                    }}
                />

There is the conflict line:

https://github.com/kfiroo/react-native-cached-image/blob/35b361695de37e4f72668c6c9c227e62ee3a87bb/CachedImage.js#L55