I need to pass image url to modal in react js. Like, on click the item from the "imgae attachment", it shows the modal with image for selected item. But it can't show my image data by passing img={item.document}, Here is my code below:
I've updated the state's structure to group the modal props.
this.state = {
deps: [],
modal: {
show: false,
img: ""
}
};
addModalClose = () => this.setState({ modal: { show: false, img: "" } });
<Button
variant="primary"
onClick={() =>
this.setState({
modal: {
show: true,
img: item.document,
},
})
}
>
image attachment
</Button>;
<AddDepositModal
show={this.state.modal.show}
onHide={this.addModalClose}
img={this.state.modal.img}
/>
