Closed tarunkonda123 closed 6 years ago
@LukeBrandonFarrell same issue
any fix? @tarunkonda123
@tarunkonda123 @akinolu52
Thanks for flagging this. I'll look into this over the next few days, publish a fix, and let you know.
ok @LukeBrandonFarrell i'll be waiting
@tarunkonda123 @akinolu52 This error occurs due to the way the library uses images. The dynamic component needs to load the resource via a URLReqeust in order to get the image dimensions for user interaction.
<Image source={{ uri: image.url }} ...
You must pass your images as URIs
URL: http://example/image.png
Image on file system: file://...example/image.png
At the moment, in order to use the dynamic collage with local (static) images you must first save them to the users filesystem temporarily and pass the URIs to the component.
Albeit, it would be possible to detect if the image is static or dynamic and then use resolveAssetSource to get the dimensions of the static image. This would allow us to use require()
or import
.
Although, it would be tricky to implement. If one of you wants to make the first attempt and PR, I'd be willing to help code this.
thanks @LukeBrandonFarrell
import React, { Component } from "react"; import { View, Text, Dimensions,Image } from "react-native"; import PropTypes from "prop-types"; import { connect } from "react-redux"; import { DynamicCollage, StaticCollage } from "react-native-images-collage";
import image1 from "../images/ic_launcher.png"; import image2 from "../images/ic_launcher.png";
export class Fifth extends Component { constructor(props) { super(props); this.state = { photos: [image1, image2] }; }
render() { return ( <DynamicCollage width={Dimensions.get("window").width / 1.1} height={Dimensions.get("window").width / 1.1} images={this.state.photos} matrix={[1, 1]} /> ); } }
const mapStateToProps = state => ({});
const mapDispatchToProps = {};
export default connect(mapStateToProps, mapDispatchToProps)(Fifth);