An open API service indexing awesome lists of open source software.

https://github.com/lorussogiacomoluca/react-context-api

Exercise #54 - 19/05/2025
https://github.com/lorussogiacomoluca/react-context-api

javascript props react usecontext-hook useeffect-hook usenavigate-hook useparams-hook usestate-hook

Last synced: about 1 month ago
JSON representation

Exercise #54 - 19/05/2025

Awesome Lists containing this project

README

          

# 📚 Esercizio 53: Esercizio di oggi: React Context API

**repo:** `react-context-api`

---

## 🚀 Consegna

Sfruttiamo le Context API per rendere disponibile la lista dei post in tutta la nostra app.

Create una nuova repo e seguite i seguenti passaggi:

1. Partiamo col definire la lista dei post all’interno di `App.jsx`
(quindi utilizzerete il primo "metodo" visto a lezione, quello più immediato, senza la personalizzazione del provider)

2. Create un componente `PostsPage.jsx` che conterrà al suo interno un titolo e un componente `PostsList.jsx` che mostra la lista di tutti i nostri post.

3. Creiamo un file per definire il nostro Context ed esportiamolo

4. Importiamo il Provider in `App.jsx` e wrappiamoci la nostra applicazione

5. Facciamo in modo che il componente `PostsList.jsx` recuperi i post consumando il Context e crei dunque una card per ciascuno di essi.

---

## 🏗️ La struttura dell’App deve essere App.jsx > PostsPage.jsx > PostsList.jsx > PostCard.jsx

---

## 📋 Ecco l'elenco dei posts

```js
const posts = [
{
id: 1,
title: "React Basis",
content:
"React apps are made out of components. A component is a piece of the UI (user interface) that has its own logic and appearance. A component can be as small as a button, or as large as an entire page.",
category: "FrontEnd",
},
{
id: 2,
title: "What is Express.js?",
content:
"Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.",
category: "Backend",
},
{
id: 3,
title: "Run JavaScript Everywhere",
content:
"Node.js® is a free, open-source, cross-platform JavaScript runtime environment that lets developers create servers, web apps, command line tools and scripts.",
category: "Backend",
},
{
id: 4,
title: "Build fast, responsive sites with Bootstrap",
content:
"Powerful, extensible, and feature-packed frontend toolkit. Build and customize with Sass, utilize prebuilt grid system and components, and bring projects to life with powerful JavaScript plugins.",
category: "Frontend",
},
];
```

---

## 🎯 Numero minimo di push: **10**

---

## 🌟 Bonus:

### Implementare un componente Alert gestito tramite Context