index.jsx 571B

1234567891011121314151617181920212223242526272829
  1. import React, { useState, useCallback } from 'react'
  2. import { Modal, Input, Icon } from 'antd'
  3. // 模拟浏览器 prompt
  4. export default props => {
  5. const [value, setValue] = useState()
  6. const handleValue = useCallback(
  7. e => setValue(e.target.value),
  8. [],
  9. )
  10. const handleOk = () => {
  11. if (props.onOk) {
  12. return props.onOk(value)
  13. }
  14. }
  15. return (
  16. <Modal
  17. {...props}
  18. destroyOnClose
  19. closable={false}
  20. maskClosable={false}
  21. onOk={handleOk}
  22. >
  23. <Input value={value} onChange={handleValue} />
  24. </Modal>
  25. )
  26. }