I’m not able to create 2 new variables using js class

  class, javascript, react-dom, reactjs

I’ve created a js class that creates a div, and here it is:

const root = document.querySelector(".root");

let app = class App {
    constructor(appName, iconSrc) {
        this.appName = appName;
        this.iconSrc = iconSrc;
        return ReactDOM.render(
            <div id={this.appName} class="app">
                <img src={this.iconSrc}></img>
                <p>{this.appName}</p>
            </div>,
            root
        );
    }
};

then, I used it to create some examples to make sure that it’s working:

const reactjs = new app(
    "reactJs",
    "./reactJslogo.png"
);

const vsCode = new app(
    "vsCode",
    "./vscodelogo.png"
);

but I can only see a vsCode icon, why?? and how to solve this

Source: Ask Javascript Questions

LEAVE A COMMENT