Skip to content

Commit 1eaf6da

Browse files
committed
resolved some issues
1 parent b99e432 commit 1eaf6da

File tree

1 file changed

+10
-0
lines changed
  • courses/react-js/begginer-level/building-your-first-react-app

1 file changed

+10
-0
lines changed

courses/react-js/begginer-level/building-your-first-react-app/MyComponent.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
1+
import React from 'react';
2+
3+
// Define a functional component using JSX
14
const MyComponent = () => {
5+
// Define some variables to use in JSX expressions
26
const name = "Ajay";
37
const isLoggedIn = true;
48
const fruits = ["apple", "banana", "orange"];
59

10+
// JSX component rendering
611
return (
712
<div>
813
<h1>Hello, {name}!</h1>
914

15+
{/* Embedding expressions */}
1016
<p>{isLoggedIn ? "You are logged in" : "Please log in"}</p>
1117

18+
{/* Defining attributes */}
1219
<img src="https://github.com/ajay-dhangar.png" alt="Ajay" style={{ width: "100px", borderRadius: "50%" }} />
1320

21+
{/* Conditionally render elements */}
1422
{isLoggedIn && <p>Welcome back, {name}!</p>}
1523

24+
{/* Mapping over arrays */}
1625
<ul>
1726
{fruits.map((fruit, index) => (
1827
<li key={index}>{fruit}</li>
1928
))}
2029
</ul>
2130

31+
{/* Compose components */}
2232
<Button text="Click me" onClick={() => alert("Button clicked!")} />
2333
</div>
2434
);

0 commit comments

Comments
 (0)