react-alert icon indicating copy to clipboard operation
react-alert copied to clipboard

Show alert in react dom tree

Open borm opened this issue 4 years ago • 1 comments

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

borm avatar Oct 06 '21 15:10 borm

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")

willemmulder avatar Nov 24 '21 10:11 willemmulder