1.0.9 • Published 2 years ago

react-use-modal-xhy v1.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

react-use-modal-xhy

安装

使用 yarn

$ yarn add react-use-modal-xhy

或者用 npm

$ npm install react-use-modal-xhy --save

使用

ModalProvider 放在组件外层

import ReactDOM from "react-dom";
import { ModalProvider } from "react-use-modal";

ReactDOM.render(
  <ModalProvider>...</ModalProvider>,
  document.querySelector("#root")
);

调用方式,以 antd 举例

使用 hooks

import React from "react";
import { Modal } from "antd";
import { useModal } from "react-use-modal-xhy";

const App = () => {
  const { showModal, closeModal } = useModal();

  function handleClick() {
    showModal(({ id, show }) => (
      <Modal
        visible={show}
        onCancel={() => {
          closeModal(id);
        }}
      >
        Modal body text goes here.
      </Modal>
    ));
  }

  return <button onClick={handleClick}>modal</button>;
};
1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago