Skip to content

Instantly share code, notes, and snippets.

@atabegruslan
Last active February 9, 2025 05:33
Show Gist options
  • Save atabegruslan/7ce2c8a0593ea34569085486d809c5a2 to your computer and use it in GitHub Desktop.
Save atabegruslan/7ce2c8a0593ea34569085486d809c5a2 to your computer and use it in GitHub Desktop.
React Components, Instances & Elements
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