Closed DanielMargolin-Taboola closed 5 years ago
@DanielMargolin-Taboola
Thanks a lot for the issue.
I think we should call confirmAlert()
again, But we have to check if there is an old element just rerender.
function createElementReconfirm (properties) {
// If has this DOM just rerender
let divTarget = document.getElementById('react-confirm-alert')
if (divTarget) {
// Rerender
render(<ReactConfirmAlert {...properties} />, divTarget)
return
}
document.body.children[0].classList.add('react-confirm-alert-blur')
divTarget = document.createElement('div')
divTarget.id = 'react-confirm-alert'
document.body.appendChild(divTarget)
render(<ReactConfirmAlert {...properties} />, divTarget)
}
// and
function createSVGBlurReconfirm () {
// If has svg ignore to create the svg
const svg = document.getElementById('react-confirm-alert-firm-svg')
if (svg) return
...
}
It will be great if you make this PR :)
Hi!
I am using your library and it's awesome! In my project I call
confirmAlert
similar to the documentation:But when
App
receives new props I want to rerender theReactConfirmAlert
.The solution I used:
In order to update the mounted
ReactConfirmAlert
with the new props, I added a new exported function calledupdateElementReconfirm
which receives properties and callsReactDOM.render
with the new properties:And then, in
App
, I did something like:Here is a link to the commit
And if you find this useful I can open a pull request :)