I am writing a image slider for my project.In there, the image will not get when I post a dynamic id with Link tag.I save the image path in 'assests/images/'.Why not show the image?Please, advice me.My code is here. This is link component.
<div>
<switch>
<Header />
<TourPackageDetail data={this.props.match.params.id} />
<Footer />
</switch>
</div>
This is the getting json api and setting the image path.
componentWillMount() {
var id=this.props.data;
return fetch('http://192.168.1.119:8080/api/viewOneTourPackage/'+id)
.then(response =>
response.json()
)
.then(responseJson => {
this.setState({
package: responseJson,
picture: responseJson.picture
});
console.log(this.state.package);
})
.catch((error) => {
console.log(error)
});
}
render() {
return (
<div class="carousel-inner" role="listbox">
{
this.state.picture.map((getIndex, i) =>
i === 0 ?
(
<div class="item active">
<img src={this.props.getIndex} alt={i} style={{ width: "100%", height: "auto" }} />
</div>
):
(
<div class="item">
<img src={this.props.getIndex} alt={i} style={{ width: "100%", height: "auto" }} />
</div>
)
)
}
</div>
)
}