Search code examples
meteorreactjsreact-routermeteor-react

How can I create a popup form in React on the document body?


I'm currently working on a React/Meteor project and in certain parts of my site want to make a sign in Popup. When the user clicks a button inside a certain component, a Popup will show up allowing the user to sign in or sign up.

I don't want to render the component within the same component as the button is in, but rather on the body of the document. What is the best way to do this? Is there a way to render a React Element dynamically. Something like:

handleClick() {
  React.render(<Popup />, document.getElementById('app'));
}

Solution

  • Of course you can. Just use ReactDOM like you normally do.

     ReactDOM.render(<Popup/>, document.getElementById('app'));
    

    You can do this as many times as you want.