Skip to main content

Command Palette

Search for a command to run...

frontend dev.(React)

Updated
β€’6 min read
frontend dev.(React)
K

I am a developer from India....


πŸ”° Overview of the 4-Day React.js Workflow

DayTopicsOutcome
1React basics, JSX, Components, Props, EventsBuild and render components
2State, useState, Conditional Rendering, ListsDynamic UI with interactive state
3useEffect, Forms, Controlled ComponentsFetch data, manage form input
4Routing (React Router), Mini ProjectComplete a mini project with navigation

πŸ“… DAY 1 – React Basics & Components

βœ… Topics Covered:

  • What is React?

  • Setting up React with Vite

  • JSX syntax

  • Functional Components

  • Props

  • Event Handling

πŸ›  Setup (Vite):

npm create vite@latest react-app -- --template react
cd react-app
npm install
npm run dev

πŸ“Œ JSX & Components

// App.jsx
function Welcome() {
  return <h1>Hello, React Learners!</h1>;
}

export default function App() {
  return (
    <div>
      <Welcome />
    </div>
  );
}

πŸ’‘ Explanation:

  • JSX is like HTML in JavaScript.

  • Welcome is a reusable functional component.


πŸ“Œ Props

function Greet(props) {
  return <h2>Hello, {props.name}</h2>;
}

// App.jsx
<Greet name="Keshav" />

πŸ“Œ Event Handling

function ButtonClick() {
  const handleClick = () => {
    alert("Button was clicked!");
  };
  return <button onClick={handleClick}>Click Me</button>;
}

πŸ›  πŸ§ͺ Mini Project 1: β€œIntroduction Card App”

Goal: Create a reusable component to display name, image, and a short bio using props.

jsxCopyEditfunction Card({ name, image, bio }) {
  return (
    <div>
      <img src={image} width="100" />
      <h3>{name}</h3>
      <p>{bio}</p>
    </div>
  );
}

// App.jsx
<Card
  name="Keshav"
  image="https://via.placeholder.com/100"
  bio="Frontend Developer"
/>

βœ… Skills Used: JSX, Props, Functional Components

πŸ“… DAY 2 – State, useState & Lists

βœ… Topics Covered:

  • State in React

  • useState Hook

  • Conditional Rendering

  • Lists and Keys


πŸ“Œ useState Hook

import { useState } from "react";

function Counter() {
  const [count, setCount] = useState(0);
  return (
    <div>
      <h2>Count: {count}</h2>
      <button onClick={() => setCount(count + 1)}>Increment</button>
    </div>
  );
}

πŸ“Œ Conditional Rendering

function LoginStatus({ isLoggedIn }) {
  return <h3>{isLoggedIn ? "Welcome Back!" : "Please Login"}</h3>;
}

πŸ“Œ List Rendering

const fruits = ["Apple", "Banana", "Cherry"];

function FruitList() {
  return (
    <ul>
      {fruits.map((fruit, index) => (
        <li key={index}>{fruit}</li>
      ))}
    </ul>
  );
}

πŸ›  πŸ§ͺ Mini Project 2: β€œTo-Do List App”

Goal: Allow user to add and delete tasks.

jsxCopyEditfunction TodoApp() {
  const [task, setTask] = useState("");
  const [list, setList] = useState([]);

  const addTask = () => {
    setList([...list, task]);
    setTask("");
  };

  const deleteTask = (index) => {
    setList(list.filter((_, i) => i !== index));
  };

  return (
    <>
      <input value={task} onChange={(e) => setTask(e.target.value)} />
      <button onClick={addTask}>Add</button>
      <ul>
        {list.map((t, i) => (
          <li key={i}>
            {t} <button onClick={() => deleteTask(i)}>❌</button>
          </li>
        ))}
      </ul>
    </>
  );
}

βœ… Skills Used: useState, lists, rendering, dynamic data handling

πŸ“… DAY 3 – useEffect, Forms & Controlled Components

βœ… Topics Covered:

  • useEffect Hook

  • Fetching Data (JSONPlaceholder)

  • Forms in React

  • Controlled vs Uncontrolled Components


πŸ“Œ useEffect & Fetch

import { useEffect, useState } from "react";

function Users() {
  const [users, setUsers] = useState([]);

  useEffect(() => {
    fetch("https://jsonplaceholder.typicode.com/users")
      .then((res) => res.json())
      .then((data) => setUsers(data));
  }, []);

  return (
    <ul>
      {users.map((user) => (
        <li key={user.id}>{user.name}</li>
      ))}
    </ul>
  );
}

πŸ“Œ Forms & Controlled Inputs

function ContactForm() {
  const [name, setName] = useState("");

  const handleSubmit = (e) => {
    e.preventDefault();
    alert(`Hello, ${name}`);
  };

  return (
    <form onSubmit={handleSubmit}>
      <input
        type="text"
        value={name}
        onChange={(e) => setName(e.target.value)}
        placeholder="Enter name"
      />
      <button type="submit">Submit</button>
    </form>
  );
}

πŸ›  πŸ§ͺ Mini Project 3: β€œUser Finder App”

Goal: Fetch and display users from API and filter them with input.

jsxCopyEditfunction UserFinder() {
  const [users, setUsers] = useState([]);
  const [query, setQuery] = useState("");

  useEffect(() => {
    fetch("https://jsonplaceholder.typicode.com/users")
      .then((res) => res.json())
      .then((data) => setUsers(data));
  }, []);

  return (
    <>
      <input
        placeholder="Search user"
        onChange={(e) => setQuery(e.target.value)}
      />
      <ul>
        {users
          .filter((user) => user.name.toLowerCase().includes(query.toLowerCase()))
          .map((user) => <li key={user.id}>{user.name}</li>)}
      </ul>
    </>
  );
}

βœ… Skills Used: useEffect, API handling, filters, controlled components

πŸ“… DAY 4 – Routing & Mini Project

βœ… Topics Covered:

  • React Router

  • Routing Pages

  • Mini Project (e.g., Contact Manager)


πŸ“Œ React Router Setup

npm install react-router-dom
// App.jsx
import { BrowserRouter, Routes, Route, Link } from "react-router-dom";
import Home from "./Home";
import About from "./About";

function App() {
  return (
    <BrowserRouter>
      <nav>
        <Link to="/">Home</Link> | <Link to="/about">About</Link>
      </nav>
      <Routes>
        <Route path="/" element={<Home />} />
        <Route path="/about" element={<About />} />
      </Routes>
    </BrowserRouter>
  );
}

🧩 Mini Project: Contact Manager App

Features:

  • Add contact

  • List contact

  • Delete contact


πŸ“Œ ContactManager.jsx

import { useState } from "react";

function ContactManager() {
  const [contacts, setContacts] = useState([]);
  const [input, setInput] = useState("");

  const addContact = () => {
    setContacts([...contacts, input]);
    setInput("");
  };

  const deleteContact = (index) => {
    const newList = contacts.filter((_, i) => i !== index);
    setContacts(newList);
  };

  return (
    <div>
      <input value={input} onChange={(e) => setInput(e.target.value)} />
      <button onClick={addContact}>Add</button>
      <ul>
        {contacts.map((c, i) => (
          <li key={i}>
            {c} <button onClick={() => deleteContact(i)}>Delete</button>
          </li>
        ))}
      </ul>
    </div>
  );
}

βœ… Final Recap & Deployment Tips

  • Use Netlify/Vercel to deploy.

  • Push code to GitHub.

  • Build static site: npm run build.

🧩 πŸŽ“ Final Project: β€œContact Manager App”

Features:

  • Add, display, delete contacts

  • Use React Router for page navigation


πŸ›  Project Structure:

bashCopyEdit/src
  β”œβ”€β”€ components/
  β”‚     └── ContactForm.jsx
  β”‚     └── ContactList.jsx
  β”œβ”€β”€ pages/
  β”‚     └── Home.jsx
  β”‚     └── About.jsx
  └── App.jsx

🧱 App.jsx

jsxCopyEdit<BrowserRouter>
  <nav>
    <Link to="/">Home</Link>
    <Link to="/about">About</Link>
  </nav>
  <Routes>
    <Route path="/" element={<Home />} />
    <Route path="/about" element={<About />} />
  </Routes>
</BrowserRouter>

🧱 ContactForm.jsx

jsxCopyEditfunction ContactForm({ onAdd }) {
  const [name, setName] = useState("");

  const handleSubmit = (e) => {
    e.preventDefault();
    onAdd(name);
    setName("");
  };

  return (
    <form onSubmit={handleSubmit}>
      <input
        placeholder="Contact name"
        value={name}
        onChange={(e) => setName(e.target.value)}
      />
      <button>Add</button>
    </form>
  );
}

🧱 ContactList.jsx

jsxCopyEditfunction ContactList({ contacts, onDelete }) {
  return (
    <ul>
      {contacts.map((c, i) => (
        <li key={i}>
          {c} <button onClick={() => onDelete(i)}>❌</button>
        </li>
      ))}
    </ul>
  );
}

βœ… Final Project Outcome:

  • Demonstrates React fundamentals

  • Full page navigation

  • Real-world use of state, props, forms, and routing


βœ… Suggested Deployment

  • Host on Netlify or Vercel

  • Build using:

bashCopyEditnpm run build

🧾 Summary

DayTopicsProject
Day 1JSX, Components, PropsIntroduction Card App
Day 2State, Lists, ConditionalsTo-Do List App
Day 3useEffect, Forms, Controlled InputUser Finder App
Day 4React RouterContact Manager App (Final Project)

Thank you