
This project is a React application demonstrating "Tab" functionality: displaying job information fetched from an external API, allowing users to switch between jobs using interactive buttons. The main learning goals are mastering React fundamentals such as state management, side effects, component structure, props, keys, and working with APIs.
- Live-Demo: https://tabs-arnob.netlify.app/
- Project Summary
- Live Demo
- Features
- Technology Stack
- Folder Structure
- Getting Started
- Step-by-Step Walkthrough
- Components Overview
- API & Data Handling
- State Management
- Example Usage
- Keywords & Concepts
- Learning & Teaching Notes
- Conclusion
- Fetches and displays job data from an external API.
- Interactive tab navigation to switch between job entries.
- Shows company, job title, dates, and a list of duties for each job.
- Dynamic UI updates via React state.
- Loading spinner/message while fetching data.
- Clean, responsive design using modern React best practices.
- Usage of unique keys for lists with the
uuid
library. - Modular component-based architecture for easy learning and reuse.
- React (Functional Components, Hooks)
- JavaScript (ES6+)
- uuid (for unique keys)
- react-icons (optional, for iconography)
- CSS (for styling)
- Fetch API (to get remote data)
- Vite or Create React App (for development server)
Tabs--React-Fundamental-Project-6/
├── public/
│ └── (static files, favicon, etc.)
├── src/
│ ├── App.jsx
│ ├── components/
│ │ ├── BtnContainer.jsx
│ │ ├── JobInfo.jsx
│ │ └── Duties.jsx
│ ├── assets/
│ │ └── (images, styles, etc.)
│ ├── index.js
│ └── styles.css
├── package.json
├── README.md
└── ...
Note: The actual structure may vary if you have additional files or folders.
git clone <repository-url>
cd <repository-directory>
npm install
npm run dev
# or, if using CRA:
npm start
- In
App.jsx
, use thefetch
API inside auseEffect
hook to get job information from the API when the component mounts. - Display a loading message or spinner while data is being fetched.
- Use
useState
to store:- The list of jobs (
jobs
) - The selected job index (
currentItem
) - Loading state (
loading
)
- The list of jobs (
- The
JobInfo
component receives the current job object as props and displays:- Company Name
- Job Title
- Dates
- Duties (using the
Duties
component)
- The
Duties
component maps over theduties
array, rendering each as a list item. - Use the
uuid
library to provide unique keys.
- The
BtnContainer
component receivesjobs
,currentItem
, andsetCurrentItem
. - Renders a button for each job/company.
- Clicking a button updates
currentItem
, changing the displayed job info.
- Install with:
npm install uuid
- Import and use:
import { v4 as uuidv4 } from "uuid";
- Use
uuidv4()
to generate unique keys for list items.
- App.jsx: Main logic, data fetching, and state management.
- BtnContainer.jsx: Renders navigation buttons for each job.
- JobInfo.jsx: Displays details for the selected job.
- Duties.jsx: Renders the list of job responsibilities.
- styles.css: Custom styles for the project.
- The app relies on an external API for job data.
- Example structure of a fetched job object:
{ "company": "Google", "dates": "Jan 2019 - Present", "title": "Frontend Developer", "duties": [ "Build UI components", "Collaborate with designers", "Write unit tests" ] }
- Data is fetched once on component mount and stored in state.
- jobs: Array of job objects fetched from API.
- currentItem: Index of the currently selected job.
- loading: Boolean indicating loading state.
Example code:
const [jobs, setJobs] = useState([]);
const [currentItem, setCurrentItem] = useState(0);
const [loading, setLoading] = useState(true);
// App.jsx
useEffect(() => {
fetch('https://course-api.com/react-tabs-project')
.then(res => res.json())
.then(data => {
setJobs(data);
setLoading(false);
});
}, []);
// Render logic:
return (
<main>
<BtnContainer jobs={jobs} currentItem={currentItem} setCurrentItem={setCurrentItem} />
<JobInfo {...jobs[currentItem]} />
</main>
);
- React, Hooks (
useState
,useEffect
) - Props and Component Communication
- Conditional Rendering (show loading state)
- List Rendering with unique keys
- Fetch API for async data
- Functional Components
- UUID for unique identifiers
- Component Modularity & Reusability
- This project is perfect for beginners to intermediate React learners.
- Focuses on real-world patterns: API calls, state handling, dynamic rendering.
- Illustrates the importance of unique keys in lists and state-driven UI.
- Encourages modular design: splitting responsibilities into components.
- Shows how to use third-party libraries (
uuid
,react-icons
) in React.
This project provides a hands-on introduction to React fundamentals, focusing on fetching and displaying external data, managing state, and building interactive tabbed interfaces. By following this example, learners can strengthen their React skills, understand component architecture, and see best practices in action.
Feel free to contribute or fork for your own learning!