1
모달 양식을 만들려면 https://react.semantic-ui.com/modules/modal을 따르고 있습니다.UI의 모달 닫기 취소 버튼에 대한 답변
Cancel
버튼을 클릭하면 모달을 닫고 싶습니다. 위의 링크에서 제안 된 속기 방법을 사용하지 않도록 제한됩니다. 어떻게 Modal 폼을 닫으려면 handleClose() 함수를 작성해야합니까?
handleClose =() => {
console.log("close")
}
render(){
return(
<Modal trigger={<Button>Upload</Button>}closeIcon>
<Modal.Content>
<p>Please upload a valid file.</p>
<Form.Input
name="upload"
label=""
type="file"
onChange={e =>
this.setState({file_data : e.target.files[0]})}
>
</Form.Input>
</Modal.Content>
<Modal.Actions>
<Button onClick = {this.handleClose}>Cancel
</Button>
<Button positive onClick = {this.handleUpload}>Upload
</Button>
</Modal.Actions>
</Modal>
);
}
멋진 솔루션 Mervyn, 버튼에 클릭 이벤트를 추가 할 필요가 없도록 모달 자체에서 onOpen 콜백을 사용할 수도 있습니다. 다른 상황에서 모달을 재사용하고 트리거를 전달하려는 경우 (예 : 기본 버튼에서 열거 나 메뉴 항목에서 열기 등) 유용합니다. – Chris