Reusable Confirmation Modal Component
In Shiprocket's dynamic logistics platform, users frequently perform critical actions such as confirming an order, updating shipment details, or deleting a manifest. To prevent accidental operations and enhance user experience, a clear confirmation step is crucial. This problem challenges you to build a reusable and accessible Confirmation Modal component that can be easily integrated into various parts of the application.
Your primary task is to create a Modal React component that facilitates user confirmation for critical actions. This component should be flexible and easy to use.
Modal Component: Develop a functional React component named Modal.title, a message (e.g., "Are you sure you want to delete this shipment?"), and two action buttons: one for Confirm and one for Cancel.isOpen state from a parent component.Modal component should accept onConfirm and onCancel callback functions, which are triggered when the respective buttons are clicked.Modal component within the provided App component, triggered by a button click.Escape key.aria-modal).Modal component is correctly implemented and reusable.App component successfully opens the modal.Escape key is pressed.onConfirm callback (e.g., logs a message to the console).onCancel callback (e.g., logs a message to the console).Constraints
App component.Loading editor...