-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFeaturedArticle.js
More file actions
28 lines (23 loc) · 797 Bytes
/
Copy pathFeaturedArticle.js
File metadata and controls
28 lines (23 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import React, { useEffect, useState } from "react";
import axios from "axios";
const FeaturedArticle = ({ name, description }) => {
const [image, setImage] = useState("");
const [text, setText] = useState("");
useEffect(() => {
// Fetch a random image from Picsum
setImage("https://picsum.photos/seed/picsum/200/300");
// Fetch random text
axios.get("https://baconipsum.com/api/?type=meat-and-filler¶s=2")
.then(response => setText(response.data.join(" ")))
.catch(error => console.error("Error fetching random text", error));
}, []);
return (
<div className="content-item">
<h3>{name}</h3>
<p>{description}</p>
<img src={image} alt="Random from Picsum" />
<p>{text}</p>
</div>
);
};
export default FeaturedArticle;