Reactjs 动态显示图像的反应模式
我正在使用react构建一个应用程序,我有一个页面,其中所有图像都会动态显示。我想在单击时在react模式中打开这些图像。如何设置要显示的图像的模式 我应该在模式中设置什么属性,以便它应用于所有图像Reactjs 动态显示图像的反应模式,reactjs,react-modal,Reactjs,React Modal,我正在使用react构建一个应用程序,我有一个页面,其中所有图像都会动态显示。我想在单击时在react模式中打开这些图像。如何设置要显示的图像的模式 我应该在模式中设置什么属性,以便它应用于所有图像类ImageModal.Component{ class ImageModal extends React.Component { constructor(props) { super(props); this.state = { showModal: false
类ImageModal.Component{
class ImageModal extends React.Component {
constructor(props) {
super(props);
this.state = {
showModal: false
};
}
setModalState(showModal) {
this.setState({
showModal: showModal
});
}
render() {
return (
<div>
<img src={ this.props.src } onClick={ this.setModalState.bind(this, true) } />
<ReactModal isOpen={ this.state.showModal }>
<img src={ this.props.src } onClick={ this.setModalState.bind(this, false) } />
</ReactModal>
</div>
)
}
建造师(道具){
超级(道具);
此.state={
showModal:错误
};
}
setModalState(showModal){
这是我的国家({
showModal:showModal
});
}
render(){
返回(
)
}
而不是使用创建新类型的组件,如