Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show alert in react dom tree #184

Open
borm opened this issue Oct 6, 2021 · 1 comment
Open

Show alert in react dom tree #184

borm opened this issue Oct 6, 2021 · 1 comment

Comments

@borm
Copy link

borm commented Oct 6, 2021

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

@willemmulder
Copy link

willemmulder commented Nov 24, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants