GA-MO / react-confirm-alert

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

How can i use this in a functional component in REACT? #82

Open ahmad6242 opened 2 years ago

ahmad6242 commented 2 years ago

I want to use this in a functional component in react but i am getting this ERROR the second time First time nothing is happening ! what should i do

react-dom.development.js:86 Warning: You are calling ReactDOMClient.createRoot() on a container that has already been passed to createRoot() before. Instead, call root.render() on the existing root instead if you want to update it
GA-MO commented 2 years ago

@ahmad6242 Upgrade your react to be version 18.x.x or use react-confirm-alert version 2.x.x for react <= 17.x.x

Demo with functional component

gustavoghp87 commented 1 year ago

About this warning (You are calling ReactDOMClient.createRoot() on a container that has already been passed to createRoot() before.), it seems to be caused by React's strict mode (index.js file), which mounts the component 2 times at a time to do checks. It would have no other consequences.