Modal
How to use the modal component
Let's start off by importing and using the Modal component
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:
toggle, show and hide functions all take one argument, which is the name of the modal. From the example above.
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?