Why we use component notation?

Hello ,
When we want make a new Instance of class component we use notation(outside of React) . while component is a class that extends React.component super class , I think we should use :
const myComponent = new [name of class we made out of React.Component] [name of object] ;
to make an object from class ,

how this relate to < /> notation ? is this still an object ? is this notation Specified for React.js and only React.js could understand it ?

when I try use this I get and error .

class Animal {
    constructor(name) {
        this.name = name;
        this._behavior = 0;
    }
    incrementBehavior() {
        this._behavior++;
    }
};

class Dog extends Animal { 
    render() {
        return <h1>hey</h1>
    }
}

const baby = new Dog; // Why we use <Dog /> is React.js instead of creating and object like this ?

console.log(baby.render()) // unexpected token <

but If I don’t use

It returns
class Animal {
    constructor(name) {
        this.name = name;
        this._behavior = 0;
    }
    incrementBehavior() {
        this._behavior++;
    }
};

class Dog extends Animal {
    render() {
        return `Hey`
    }
}

const baby = new Dog;

console.log(baby.render())  // returns Hey

those tags are not part of javascript, you’d need an additional compilation step to turn tags into js code

1 Like