Semantic react ui Popup close button
According to the docs, you have to create a controlled Popup.
Create a component which nests the Popup
component, and maintain a state in it:
class ControlledPopup extends React.Component {
constructor() {
super();
this.state = {
isOpen: false
}; // state to control the state of popup
}
handleOpen = () => {
this.setState({ isOpen: true });
}
handleClose = () => {
this.setState({ isOpen: false });
}
render() {
return (
<div>
<Popup
trigger={<button>click to open</button>}
content={<button onClick={this.handleClose}>click to close</button>}
on='click'
open={this.state.isOpen}
onOpen={this.handleOpen}
/>
</div>
);
}
}