Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(component): new hook to open confirm modal #6342

Merged
merged 1 commit into from
Mar 27, 2024

Commits on Mar 27, 2024

  1. feat(component): new hook to open confirm modal (#6342)

    new exports from `@affine/component`:
    ```ts
    import { ConfirmModalProvider, useConfirmModal } from "@affine/component"
    ```
    
    Open confirm modal with hook:
    
    ```ts
    const Component = () => {
      const { openConfirmModal } = useConformModal();
    
      const open = () => {
        openConfirmModal({
          // props of ConfirmModal
          /**
           * will show loading state when confirm clicked, and close after onConfirm finished
           */
          onConfirm: async () => {
            await new Promise((r) => setTimeout(r, 2000));
          },
        });
      }
      return <Button onClick={open}>Open</Button>
    }
    ```
    CatsJuice committed Mar 27, 2024
    Configuration menu
    Copy the full SHA
    d412635 View commit details
    Browse the repository at this point in the history