npm create vite@latest
npm install
npm run dev
Last active
February 9, 2025 05:33
-
-
Save atabegruslan/7ce2c8a0593ea34569085486d809c5a2 to your computer and use it in GitHub Desktop.
React Components, Instances & Elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { StrictMode } from 'react' | |
import { createRoot } from 'react-dom/client' | |
import './index.css' | |
import App from './App.jsx' | |
class MyComponent extends React.Component { | |
constructor(props) { | |
super(props); | |
console.log('This is a component instance:', this); | |
} | |
render() { | |
const another_element = <div>Hello, World! </div>; | |
console.log('This is also an element:', another_element); | |
return another_element; | |
} | |
} | |
console.log('This is a component:', MyComponent); | |
const element = <MyComponent/>; | |
console.log('This is an element:', element); | |
createRoot(document.getElementById('root')).render( | |
<StrictMode> | |
{/*<App />*/} | |
<MyComponent /> | |
</StrictMode>, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment