GA-MO / react-confirm-alert

react component confirm dialog.
https://ga-mo.github.io/react-confirm-alert/demo/
MIT License
272 stars 105 forks source link

Exporting new function which rerenders the ReactConfirmAlert componen… #17

Closed DanielMargolin-Taboola closed 5 years ago

DanielMargolin-Taboola commented 5 years ago

Exporting new function which rerenders the ReactConfirmAlert component with the given properties

GA-MO commented 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

  ...
  ...

}
DanielMargolin-Taboola commented 5 years ago

Hi @GA-MO, I agree with you 👍 I made the changes as you suggested (in createElementReconfirm I preferred using if else statements cause I thought it will be a little bit more readable).