Modal
How to use the modal component
Let's start off by importing and using the Modal component
// import
import Modal from "@wigxel/react-components/libs/cards"
// usage
<Modal
name="profile-modal"
onClose={() => console.log("Profile Modal closed")}>
<Message />
<Buttons />
</Modal>The Modal component comes with two helper functions. The first:
Dealing with Multiple Modals
When working with mutliple modals in a project the above usage can be exhausting. A more friendly approach will be utilizing the useModal hook and Modal.Provider context.
Modal.useModal
This helper function, just like the naming convention implies is a hook. This hook takes zero arguments and exports the followings:
The Modal.useModal()won't work without the <Modal.Provider>context wrapper.
Modal.Provider
The <Modal.Provider>context should wrap the root component before calling the Modal.useModal() function. For example:
Modal Props
Last updated
Was this helpful?