chunkai1312 / muibox

Promise-based dialog boxes (alert, confirm, prompt) using Material-UI
https://chunkai1312.github.io/muibox
MIT License
20 stars 6 forks source link

fix: Fixes multiple rerenders in applications #13

Closed VagnerNico closed 4 years ago

VagnerNico commented 4 years ago

I had a problem recently in my application that makes my app rerenders multiple times, so removing the dialog from the render method and turning him to be a class object prevent those rerenders.

Done

VagnerNico commented 4 years ago

To give some context to this pull request, I use your lib to show some alerts on my redux-sagas, like when there are a response error or internet issues, forwarding the dialog as an action parameter because I can't call a hook inside sagas. So, assigning one of those actions in the useEffect and the dialog in the array of dependencies triggers useEffect each time my component re-render. This pull request fixes these re-renders by not reassigning the dialog object on each MuiBox Dialog re-render.

chunkai1312 commented 4 years ago

@VagnerNico The fix has been released. Thank you!