Guest User

Untitled

a guest
Feb 2nd, 2023
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from "react";
  2. import ReactDOM from 'react-dom/client';
  3.  
  4. class MyComponent extends React.Component {
  5.   render() {
  6.     const greeting = "Hello, World!";
  7.     const mylist = ["carrot", "tomato"];
  8.  
  9.     return (
  10.       <div>
  11.         <h1>{greeting}</h1>
  12.         <p>This is my first React component.</p>
  13.         <ul>
  14.           {
  15.             mylist.map((item,index) => (
  16.                <li key={index}>{item}</li>))
  17.            }
  18.         </ul>
  19.       </div>
  20.     );
  21.   }
  22. }
  23.  
  24. const component = new MyComponent()
  25.  
  26. const body = ReactDOM.createRoot(document.querySelector('body'));
  27. body.render(component.render());
  28.  
Advertisement
Add Comment
Please, Sign In to add comment