import React, { MouseEvent } from 'react'; import { CSSTransition } from 'react-transition-group'; import SMask from '@components/SMask'; import SModal from '@components/SModal'; import './style.less'; interface Props { title?: string; willUnmount?: () => void; } interface State { visible: boolean; } class SMessageBox extends React.PureComponent { constructor(props: Props) { super(props); this.state = { visible: false }; this.handleHide = this.handleHide.bind(this); this.handleContentClick = this.handleContentClick.bind(this); this.onExited = this.onExited.bind(this); } componentDidMount() { this.setState({ visible: true }); } render() { const { children, title } = this.props; const { visible } = this.state; const maskComp = ( ); return (
{maskComp}
this.handleContentClick(e)}>

{title}

); } handleHide() { this.setState({ visible: false }); } handleContentClick(e: MouseEvent) { e.stopPropagation(); console.log('handleContentClick'); } onExited(node: HTMLElement) { this.props.willUnmount(); } } export default SMessageBox;