All files / src/popconfirm/_example PopConfirmExample.jsx

33.33% Statements 2/6
100% Branches 0/0
33.33% Functions 1/3
33.33% Lines 2/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42          1x   1x                                                                    
import React, { useState, Fragment } from "react";
import { PopConfirm } from "@tencent/tea-component/lib/popconfirm";
import { Button } from "@tencent/tea-component/lib/button";
 
export default function PopConfirmExample() {
  const [confirmVisible, setConfirmVisible] = useState(false);
 
  return (
    <PopConfirm
      title="确定要解除关联?"
      message="解除后,配置将不再生效,也不做关联。"
      visible={confirmVisible}
      onVisibleChange={setConfirmVisible}
      footer={
        <Fragment>
          <Button
            type="link"
            onClick={() => {
              setConfirmVisible(false);
              console.log("已解除");
            }}
          >
            解除
          </Button>
          <Button
            type="text"
            onClick={() => {
              setConfirmVisible(false);
              console.log("已取消");
            }}
          >
            取消
          </Button>
        </Fragment>
      }
      placement="top-start"
    >
      <Button type="text">解除关联</Button>
    </PopConfirm>
  );
}