TGViewer
Web Development Web Development @webdevcoursefree · 79.6K subscribers
Post #3555 4.19K
Now, let's move to the next topic in Web Development Roadmap:

⚛️ Simple CRUD UI in React

Now you learn how real apps work.

👉 CRUD = Create, Read, Update, Delete

Every real application uses CRUD.

Examples
• Add task → Create
• View tasks → Read
• Edit task → Update
• Delete task → Delete

🔹 What is CRUD in React

CRUD means managing data using UI.

React handles CRUD using:
✅ State
✅ Events
✅ Components

 

🧠 Why CRUD is Important
• Used in dashboards
• Used in admin panels
• Used in e-commerce apps
• Top interview question

If you know CRUD → you can build real apps.
 

🧩 Example Project: Todo List CRUD
We will build:
✔ Add item
✔ Show item
✔ Delete item
✔ Update item

 

✍️ Step 1: Setup State
State stores list data.
import { useState } from "react";
function App() {
  const [items, setItems] = useState([]);
  return <div></div>;
}
export default App;

✔ items → list data 
✔ setItems() → update list

 

➕ Step 2: Create (Add Item)
Add new item to list.
const [input, setInput] = useState("");
const addItem = () => {
  setItems([...items, input]);
  setInput("");
};

UI
<input value={input} onChange={(e) => setInput(e.target.value)} />
<button onClick={addItem}>Add</button>


 

👀 Step 3: Read (Show Items)
Display list using map.
<ul>
  {items.map((item, index) => (
    <li key={index}>{item}</li>
  ))}
</ul>


 

❌ Step 4: Delete Item
Remove item from list.
const deleteItem = (index) => {
  const newItems = items.filter((_, i) => i !== index);
  setItems(newItems);
};

UI
<button onClick={() => deleteItem(index)}>Delete</button>


 

✏️ Step 5: Update Item (Edit)
Update existing data.
const updateItem = (index) => {
  const newValue = prompt("Update item");
  const updated = [...items];
  updated[index] = newValue;
  setItems(updated);
};

UI
<button onClick={() => updateItem(index)}>Edit</button>


 

✅ Complete CRUD UI Example
import { useState } from "react";
function App() {
  const [items, setItems] = useState([]);
  const [input, setInput] = useState("");
  const addItem = () => {
    if (!input) return;
    setItems([...items, input]);
    setInput("");
  };
  const deleteItem = (index) => {
    setItems(items.filter((_, i) => i !== index));
  };
  const updateItem = (index) => {
    const newValue = prompt("Update item");
    if (!newValue) return;
    const updated = [...items];
    updated[index] = newValue;
    setItems(updated);
  };
  return (
    <div>
      <h2>Todo CRUD</h2>
      <input value={input} onChange={(e) => setInput(e.target.value)} />
      <button onClick={addItem}>Add</button>
      <ul>
        {items.map((item, index) => (
          <li key={index}>
            {item}
            <button onClick={() => updateItem(index)}>Edit</button>
            <button onClick={() => deleteItem(index)}>Delete</button>
          </li>
        ))}
      </ul>
    </div>
  );
}
export default App;


 

🧠 How CRUD Works Internally
• User action → event triggers
• State updates
• React re-renders UI

This is React’s core workflow.

 

⚠️ Common Beginner Mistakes
• Mutating state directly
• Forgetting key in list
• Not copying arrays before update
• Confusing state updates

 

🧪 Mini Practice Task
• Build a simple student list CRUD
• Add student name
• Edit student name
• Delete student
• Show total count


✅ Double Tap ♥️ For More
  • ❤ 12
  • 🔥 1
More from @webdevcoursefree
  1. Oct 14, 2026🌐 Web Development Roadmap — Part 17 HTML Images — <img> Tag Images make webpages more vis…
  2. Oct 13, 2026𝗧𝗢𝗣 𝗙𝗥𝗘𝗘 𝗖𝗢𝗨𝗥𝗦𝗘𝗦 𝗧𝗢 𝗕𝗢𝗢𝗦𝗧 𝗬𝗢𝗨𝗥 𝗦𝗞𝗜𝗟𝗟𝗦 𝗜𝗡 𝟮𝟬𝟮𝟲! Explor…
  3. Oct 12, 2026For example: Go to Profile → <a> Submit Form → <button> Open Article → <a> Delete Account…
  4. Oct 12, 2026🌐 Web Development Roadmap — Part 16 HTML Links — Tag Links are one of the most important…
  5. Oct 12, 2026🚀 𝗪𝗵𝗶𝗰𝗵 𝗧𝗲𝗰𝗵 𝗦𝗸𝗶𝗹𝗹 𝗪𝗶𝗹𝗹 𝗬𝗼𝘂 𝗠𝗮𝘀𝘁𝗲𝗿 𝗶𝗻 𝟮𝟬𝟮𝟲? Want to buil…
  6. Oct 9, 2026Post #4079
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →