import React from 'react'; import Dialog from './index'; let div; export default function (props) { let d; props = props || {}; props.iconClassName = props.iconClassName || 'anticon-exclamation-circle'; let width = props.width || 375; function close() { d.setState({ visible: false }); } function onCancel() { let cancelFn = props.onCancel; if (cancelFn) { let ret; if (cancelFn.length) { ret = cancelFn(close); } else { ret = cancelFn(); if (!ret) { close(); } } if (ret && ret.then) { ret.then(close); } } else { close(); } } function onOk() { let okFn = props.onOk; if (okFn) { let ret; if (okFn.length) { ret = okFn(close); } else { ret = okFn(); if (!ret) { close(); } } if (ret && ret.then) { ret.then(close); } } else { close(); } } let body =
{props.title}
{props.content}
; let footer =
; if (!div) { div = document.createElement('div'); document.body.appendChild(div); } React.render(
{body} {footer}
, div, function () { d = this; }); }