Skip to content

Correct way of adding multiple alert dialogs #3875

Answered by baydisng13
dwalker93 asked this question in Q&A
Discussion options

You must be logged in to vote

Simplifying Alert Dialog Usage for Multiple Alert Dialogs

If your application requires multiple instances of Alert Dialogs, follow these steps to ensure a streamlined and maintainable implementation:

Step-by-Step Guide

Step 1: Prepare a Global State

Start by setting up a global state to manage the state of your Alert Dialogs. This can be achieved using Zustand or React's Context API for centralized state management.

// confirmationStore.ts
import { create } from "zustand";

interface ConfirmationState {
  open: boolean;
  title: string | null;
  description: string | null;
  cancelLabel: string | null;
  actionLabel: string | null;
  onAction: () => void;
  onCancel: () => void;
}

interface

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@dwalker93
Comment options

@antonin-beev
Comment options

@baydisng13
Comment options

Answer selected by dwalker93
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants