,

Part 1 – Architecture of CRUD Example App using ReactJS Framework 18 with Axios, Json-Server, and Hooks

Posted by



ReactJS Framework 18 – Architecture – CRUD Example App – Axios – Json-Server – Hooks – Part 1

ReactJS is a powerful JavaScript library used for building user interfaces. It provides a component-based architecture that allows developers to create reusable UI elements. In this article, we will explore the architecture of a CRUD (Create, Read, Update, Delete) example app using ReactJS and various tools such as Axios, JSON-Server, and Hooks.

To get started, let’s first understand the basic structure of a ReactJS app. A ReactJS app is composed of multiple components. Each component represents a specific part of the user interface. Components can have sub-components, forming a hierarchical structure.

One of the most significant features of ReactJS is its virtual DOM (Document Object Model). ReactJS uses a virtual DOM to efficiently update only the parts of the user interface that have changed, instead of re-rendering the entire page. This results in better performance and responsiveness.

To demonstrate the CRUD functionality, we will be using the Axios library for making HTTP requests from the React app to a server. We will also be using JSON-Server, a lightweight server that allows us to mock a RESTful API using a JSON file as a data source.

Now, let’s understand how Hooks work in ReactJS. Hooks are functions that allow developers to use state and other React features without writing a class. Hooks provide a more concise and straightforward way to manage state in functional components.

To create our CRUD example app, we will start by setting up the project structure. Open your preferred text editor and create the following files:

1. index.html
2. App.js
3. Package.json
4. data.json

In the “index.html” file, add the following HTML structure:

“`





React CRUD Example



“`

In the “App.js” file, write the following code:

“`jsx
import React from ‘react’;

function App() {
return (

React CRUD Example

{/* Rest of the code goes here */}

);
}

export default App;
“`

In the “Package.json” file, add the following code:

“`json
{
“name”: “react-crud-example”,
“version”: “1.0.0”,
“description”: “A CRUD example app using ReactJS”,
“scripts”: {
“start”: “react-scripts start”
},
“dependencies”: {
“axios”: “^0.24.0”,
“react”: “^18.0.0”,
“react-dom”: “^18.0.0”,
“react-scripts”: “^5.0.0”
},
“devDependencies”: {},
“browserslist”: {
“production”: [
“>0.2%”,
“not dead”,
“not op_mini all”
],
“development”: [
“last 1 chrome version”,
“last 1 firefox version”,
“last 1 safari version”
]
}
}
“`

Finally, in the “data.json” file, add some sample data that will be used in our CRUD example:

“`json
[
{
“id”: 1,
“title”: “ReactJS”,
“description”: “A JavaScript library for building user interfaces”
},
{
“id”: 2,
“title”: “Vue.js”,
“description”: “A progressive JavaScript framework”
},
{
“id”: 3,
“title”: “Angular”,
“description”: “A platform for building web applications”
}
]
“`

Now that we have set up the basic structure of our project, we are ready to move on to the next part, where we will start implementing the CRUD functionality using Hooks, Axios, and JSON-Server.

In the next part of this series, we will create the necessary components and use Hooks to manage the state of our app. We will also use Axios to fetch data from the JSON-Server and render it on the UI.

Stay tuned for Part 2 of this article, where we will dive deeper into the implementation details of our ReactJS CRUD example app.

To be continued…

(Note: The examples provided in this article are based on ReactJS version 18 and may differ slightly from previous or future versions.)

0 0 votes
Article Rating
20 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Amine BEN AICHA
1 year ago

Merci bcq Professeur, si tu pourrais svp partager la Part 2 ça sera top

Delmas Angaman
1 year ago

bonsoir professeur svp la partie 2 react-json-server-auth-best-practises 🙏

Nephthali Tutondele
1 year ago

Merci beaucoup professeur Youssfi 🙏🏼

mohamed benyghil
1 year ago

we need PART2 thanks

AMA Tutoriel
1 year ago

Au moins un crud en français. Merci

kevin Tonbong
1 year ago

Je vous Kif Grave 😍.

0x4ns
1 year ago

Thank you, please if it's possible make that in a github repository

Abdoulaye Diao
1 year ago

Bravo professeur, très clair et précis.

achraf
1 year ago

c la premiere fois que je vois du contenu arabe qui parle des frameworks js pendatn 3h , vous faites un travail parfait .merci pour vos efforts

fadil njoya
1 year ago

MERCI pour votre travail

Abdoul Karim Diallo
1 year ago

Merci je voulais savoir si possibles d'avoir une explication sur Codeigneter 3

Fall
1 year ago

React redux s’il vous plaît

Fall
1 year ago

Le meilleur de tous les temps

Franck Lepage
1 year ago

parfait , merci monsieur youssfi pour vos efforts

coulibaly leni
1 year ago

Papa Yousfi! Toujours au top level toujours

NOTA نوتة
1 year ago

👏👏👏👏

Philippe ARRAS
1 year ago

Merci 🎉

MAMADOU ALPHA Barry
1 year ago

Enfin Voila; merci Monsier

Mahdi Elhajuojy
1 year ago

Je vous remercie pour vos efforts.

Remy Moro
1 year ago

Bonjour je voulais savoir pour commencer sur java ?
Quelle cours vous recommanderiez ?