By the end of this session, students will be able to create class and functional components, style components using CSS, and perform CRUD operations in React using MockAPI. The project will be named "my-product-management-system" and will include pages to register categories and products.
By the end of this session, students will be able to create class and functional components, style components using CSS, and perform CRUD operations in React using Own/MockAPI. The project will be named "my-product-management-system" and will include pages to register categories and products.
## Agenda:
### 1. Introduction (30 minutes)
### 1. Introduction (10 minutes)
- Overview of React components: class components vs functional components.
- Introduction to React's component lifecycle methods.
- Brief introduction to CSS in React.
- Introduction to MockAPI for CRUD operations.
### 2. Setting Up the Project (30 minutes)
### 2. Setting Up the Project (5 minutes)
- Create a new React project using Create React App.
- Start the React development server.
- Brief overview of the project's folder structure.
\`\`\`bash
```bash
npx create-react-app my-product-management-system
cd my-product-management-system
npm start
\`\`\`
```
\`\`\`
### 3. Editing App.js (3 minutes)
- Modify \`App.js\` to include set title project / Hello World! to test this app.js page
```bash
import React from 'react';
import { BrowserRouter as Router, Route, Link } from 'react-router-dom';
import CategoryFormClass from './components/Category/CategoryFormClass';
import ProductFormClass from './components/Product/ProductFormClass';
function App(){
return(
<Router>
<div className="App">
<h1>Product Management System</h1>
</div>
</Router>
);
}
export default App;
```
### 4. Setting Up the Project Folder Structure / File System (10 minutes)
- Create folder and file according to below file structure page
- Brief overview of the project's folder structure.
```bash
my-product-management-system/
├── public/
│ ├── index.html
...
...
@@ -49,37 +76,15 @@ my-product-management-system/
│ └── ...
├── package.json
└── ...
\`\`\`
### 3. Editing App.js (15 minutes)
- Modify \`App.js\` to include a welcome message and links to the category and product registration pages.
```
\`\`\`jsx
import React from 'react';
import { BrowserRouter as Router, Route, Link } from 'react-router-dom';
import CategoryFormClass from './components/Category/CategoryFormClass';
import ProductFormClass from './components/Product/ProductFormClass';
function App() {
return (
<Router>
<divclassName="App">
<h1>Product Management System</h1>
</div>
</Router>
);
}
export default App;
\`\`\`
### 4. Creating Class Components (60 minutes)
### 4. Creating Class Components (30 minutes)
- Deep dive into creating class components.
- Create `CategoryFormClass.js` and `CategoryListClass.js` as class components.
- Discuss state management, event handling, and lifecycle methods.
CategoryFormClass.js
```bash
\`\`\`jsx
// CategoryFormClass.js
import React, { Component } from 'react';
import { createCategory } from '../../services/ApiCategory';
...
...
@@ -102,7 +107,7 @@ class CategoryFormClass extends Component {
};
render(){
const { name, description } = this.state;
const { name, description }= this.state
return(
<form onSubmit={this.handleSubmit}>
...
...
@@ -127,10 +132,10 @@ class CategoryFormClass extends Component {
- 3rd-Party libary like axios,sweertalert,formik,bootstrap/tailwind
- Implementing more complex forms and validation.
- Error handling and debugging tips.
This comprehensive 5-hour training module ensures that students gain an in-depth understanding of React components, styling, and CRUD operations, with ample time for hands-on practice and advanced topics.
## Prerequisite Topics
-[Explore project files and folders](https://reactjs.org/docs/getting-started.html)
-[Server-Side Rendering (SSR) with Next.js](https://nextjs.org/docs)
-[Animation in React](https://reactcommunity.org/react-transition-group/)
This comprehensive 4-hour training module ensures that students gain an in-depth understanding of React components, styling, and CRUD operations, with ample time for hands-on practice and advanced topics.