Passing params
Last updated
Was this helpful?
Last updated
Was this helpful?
One of the reasons we love React so much is how easy it is to reuse the same component wherever it makes sense. We might want to do something similar here: calling different modals, but rendering the same React component under the hood. Being able to change the content depending on which context that modal was called from is a major key to success, hence the need for params
!
They are a two-step-use tool:
We pass params to a modal by putting them as second argument, ie: openModal('ErrorModal', { message: 'No Internet connection' })
We access the params in the modal component through modal.params
.
Since Modalfy v2, you can even have granular access to your params if you used an object as params
(which you should by default) and even provide a default value:
Checkout the API reference to learn more about getParam().