eBay / nice-modal-react

A modal state manager for React.
https://ebay.github.io/nice-modal-react
MIT License
1.96k stars 109 forks source link

How to bind props update via use NiceModal.show(MyModal, { loading, onOk }) #156

Open FatDoge opened 1 month ago

FatDoge commented 1 month ago

I will send props.onOk, maybe async function, it will change loading status from false -> true -> false when user clicks button inside a modal. What I need is binding loading props and add loading style on clicked button, but I found it didn't work.

supnate commented 1 month ago

See the example here: https://opensource.ebay.com/nice-modal-react/#propsBinding

FatDoge commented 1 month ago

yes I saw it, but it needs to add additional ModalHolder and other code. If just use NiceModal.show(MyModal, { loading, onOk }), can it bind props?

FatDoge commented 1 month ago

Or why not provide a optional object like NiceModal.show(MyModal, { loading, onOk }, { refreshDeps: [loading] })

supnate commented 1 month ago

Or why not provide a optional object like NiceModal.show(MyModal, { loading, onOk }, { refreshDeps: [loading] })

Data binding can only be used in hooks or components.