I was looking for a solution to use a re-usable model dialog window, but where I have freedom of content, and came to the High-Level Component pattern in React. As described here: https://stackoverflow.com/a/31564812.
While this initially seems to work, I am running into trouble when I use one wrapper to wrap different things (at different times).
First I do:
function Dialog(Component) {
    return React.createClass({
        render: function() {
            return ( 
                <div className="wrapper"> 
                    before 
                    <Component {...this.props}/>
                    after
                </div>
            );
        }    
    });
};
module.exports = Dialog;
And then I do:
var Dialog = require('./Dialog.jsx');
DialogContent = React.createClass({
    render: function () {
      return ( 
        <div> blah blah this is for login</div>
      )
    };
};                                      
var LoginDialogWindow = new Dialog(DialogContent);
module.exports = LoginDialogWindow;
And
 var Dialog = require('./Dialog.jsx');
 OtherContent = React.createClass({
        render: function () {
          return ( 
            <div>Jo Jo, this is something else</div>
          )
      };
  };                                      
  var OtherDialogWindow = new Dialog(OtherContent);
  module.exports = OtherDialogWindow;
Then what I get is that these two components share their state. When one is defined the other will show the same text as the first. Wen I call a function on one, the function appears be called on the other as well. What I see is that when I open one flavor of dialog window, both flavors appear.
I'm guessing it has something to do with JavaScript closures, but am at a loss of how to approach this. How do I use these separately?
 
     
    