REACT SLIP 02 - Fetch Users with useEffect
Marks: 12 | Source: original question PDF page 2
Concepts: useEffect, fetch, useState

A. RUN THE READY PROJECT (recommended)
1. Install Node.js 22 LTS (22.12+), and VS Code. Check in terminal:
   node -v
   npm -v
2. Open the slip2 folder in VS Code (File > Open Folder).
3. Terminal > New Terminal. Make sure the terminal is inside slip2, where package.json exists.
4. Run:
   npm install
5. Run:
   npm run dev
6. Open the Local URL shown in terminal (usually http://localhost:5173/).
7. For console output, press F12 > Console in Chrome. Keep the browser and terminal open.
8. To stop the server, press Ctrl+C in the terminal.
9. Optional production compilation: npm run build
   Optional preview after build: npm run preview

B. CREATE FROM SCRATCH (exam revision)
1. Open CMD / VS Code terminal in an EMPTY parent folder, outside the ready project.
2. Create a fresh React app named react-slip-02:
   npm create vite@6 react-slip-02 -- --template react
   cd react-slip-02
   If asked to install create-vite, answer y.
3. Replace the scaffold package.json with this slip's supplied package.json (keeps the same dependencies).
   Copy the supplied index.html and entire src folder into the new project, replacing matching files.
   Copy public/ if supplied. Delete any unused scaffold files only if desired.
   This project uses Vite's built-in JSX transform with explicit React imports;
   remove the scaffold vite.config.js/ts if present (the extra plugin is not required).
4. Install dependencies:
   npm install
   Additional library commands if installing individually: None.
5. Start: npm run dev
6. Open the Local URL in browser. F12 > Console if needed.

C. FILES TO STUDY
index.html, package.json, src/main.jsx, src/App.jsx, src/index.css
Read QUESTION.txt for the original task. The primary answer code is src/App.jsx.

D. EXPECTED OUTPUT AND MANUAL CHECK
With internet access, the API returns a users list (normally 10 users); names appear on UI and complete objects in console. If network fails, an error message appears. The external API is required for successful fetching.
   Internet is necessary to fetch the API in this practical.

E. COMMON PROBLEMS
- npm not recognized: install Node.js, then reopen VS Code.
- npm.ps1 blocked: select Command Prompt terminal or run npm.cmd install and npm.cmd run dev.
- Missing package.json: cd into the correct slip2 folder.
- Cannot find module: npm install in this project's folder.
- Port 5173 busy: use the actual Local URL printed by Vite, or stop the other server.
- No console output: open Chrome DevTools Console and clear filters.
- Do not double-click index.html; Vite serves the JSX modules.
