[IOS]RN 0.33 Support for defaultImageSource
See original GitHub issueHi @anvilabs . Great work, This component looks awesome. I have successfully integrated into my react project. But got one small Issue.
When passing the props to the component (renderContent) I am also passing the defaultSource
which is a static file on the project folder . This works fine with the thumbnails but when loading the fullscreen view it shows a black view not the defaultSource. below is the code I have used.
Render Method
return ( <View> <Text style={styles.sectionHeaderText}>ADDITIONAL IMAGES</Text> <View style={styles.additionalImageContainer}> <ImageCarousel ref={(imageCarousel: ImageCarousel) => { this._imageCarousel = imageCarousel; }} renderContent={this.renderImage} > {this.state.imageList.map((url: string): ReactElement<any> => ( <Image style={styles.thumbnailImage} key={Math.random()} source={{uri:url}} defaultSource={{uri: './images/placeholder.jpg'}} /> ))} </ImageCarousel> </View> </View> )
renderImage method
return ( <Image style={styles.imageViewerImage} resizeMode={'contain'} onLoadStart={this.onImageLoadStart(i)} source={{uri:this.state.imageList[i]}} defaultSource={{uri: './images/placeholder.jpg'}} /> );
Is there anything I need to do to fix it…
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
The Image cache reset issue was because my apps default cache size being depleted. Added the following to
Appdeligate.m
didFinishLaunchingWithOptions
method to increase it to 200 MB fixed the image cache resetting and now it works.// Set app-wide shared cache NSUInteger cacheSizeMemory = 200*1024*1024; // 200 MB NSUInteger cacheSizeDisk = 200*1024*1024; // 200 MB NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"]; [NSURLCache setSharedURLCache:sharedCache];
Hi, thank you for the issue. renderContent Image must have
flex: 1
to fill the fullscreen view. If that doesn’t help you, please share whole component’s source code in a gist.