I would like to create a generic Modal for different confirmations/errors and or infos.
How would I be able to create a modal that can be initialized with some text and the calling method respond to the boolean result there of.
Similar to :
if (confirm(“Are you sure?”))
{
//do something
}
else
{
//do something else
}
Hey! This can be done by using JS async-await and storeValue functions.
Steps -
- Create an async function
- Store the confirmation message in store using
await storeValue(...)
syntax - Open modal at last
- In your modal use the stored message value to show the confirmation text
- Create a function to conditionally trigger the relevant actions from modal