react-alert
react-alert copied to clipboard
Show alert in react dom tree
Really good library, but what about something like that
const App = () => {
const reactDomAlert = useAlert();
return (
<div id="app">
<AlertContainer />
... some components with logic here
</div>
)
}
so, the main idea to not attach all alerts to document body element, sometimes we need to show alert as static/relative position inside react
Yes, exactly my issue. I want the alert to show up in a specific spot in the DOM. A solution could be to have a 'AlertPlaceholder' component that we could drop anywhere in the DOM tree (with potentially a specific indication of the intended context), and that would then be used as a container for the alerts?
Note: trying to use the AlertProvider in a different spot in the DOM does not work and gives me errors ("Cannot read property 'current' of undefined")