Declined
Vous développez une section FAQ pour votre app. La section FAQ doit afficher différentes catégories de questions fréquemment posées, avec une page dédiée à chaque catégorie avec une route dynamique. Vous avez un fichier page.js dans app/faq/[category] pour gérer l'affichage des questions par catégorie.
// app/faq/[category]/page.js
import { fetchDataForCategory } from '../../lib/api';
export default function FAQPage({ params }) {
const category = params.category;
const [faqData, setFaqData] = useState(null);
useEffect(() => {
fetchDataForCategory(category)
.then(data => setFaqData(data))
.catch(error => console.error('Erreur de chargement des FAQ', error));
}, [category]);
return (
<div>
<h1>FAQ: {category}</h1>
{faqData ? (
<ul>
{faqData.map(faq => <li key={faq.id}>{faq.question}</li>)}
</ul>
) : (
<p>Chargement...</p>
)}
</div>
);
}
// fetchDataForCategory est une fonction qui appelle une API pour récupérer les données de FAQ pour une catégorie donnée.
Dans ce scénario, quelle est la meilleure pratique pour charger et afficher les données d'une FAQ spécifiques à une catégorie dans app/faq/[category]/page.js
Author: AnasStatus: DeclinedQuestion not yet passed
This question was declined for the following reason: Question Other. You can publish an alternative question.
0
Community EvaluationsNo one has reviewed this question yet, be the first!
4
Add global middleware to handle authentication across all routes in your application in Next.js11
What are the benefits of using dynamic imports in Next.js?4
Fetch the product details from the server on every request and cache it.13
What is the path to the about page in Next.js?19
Load blog post data at build time for a static render.9
What's the main new feature of Next.js 13 compared with previous versions?9
How to use Incremental Static Regeneration (ISR) in Next.js to update blog posts periodically after their initial publication.