import React, { useState, useEffect } from
"react"
;
import
"bootstrap/dist/css/bootstrap.min.css"
;
import { Spinner, Button, Container } from
"react-bootstrap"
;
function
App() {
const [loading, setLoading] = useState(
false
);
const [data, setData] = useState([]);
const [showSpinner, setShowSpinner] = useState(
false
);
useEffect(() => {
if
(loading) {
setShowSpinner(
true
);
fetchData().then((result) => {
setData(result);
setLoading(
false
);
setShowSpinner(
false
);
});
}
}, [loading]);
async
function
fetchData() {
return
new
Promise((resolve) => {
setTimeout(() => {
resolve([
`Company Profile and Brand:`,
`GeeksforGeeks is a leading platform
for
computer science resources and coding challenges.`,
`Founded
in
2009 by Sandeep Jain, the platform
has become a trusted source
for
developers, students, and
professionals`,
`It offers a wide range of tutorials, practice problems,
articles, and courses
in
various programming languages and
technologies`,
`GeeksforGeeks is known
for
its competitive programming
challenges and coding contests.`,
`The platform has a strong community of contributors and
learners who help each other grow their skills`,
`Whether you are a beginner or an experienced developer,
GeeksforGeeks has resources to suit your needs.`,
`Join the GeeksforGeeks community today and accelerate
your learning journey!`,
]);
}, 2000);
});
}
return
(
<Container className=
"mt-4"
>
{
" "
}
<div className=
"jumbotron text-center bg-light"
>
{
" "
}
<h1 className=
"text-success"
>
GeeksforGeeks
</h1>
{
" "
}
<p>
{
" "
}
A leading platform
for
computer science
resources and coding challenges.
{
" "
}
</p>
{
" "
}
<Button
variant=
"primary"
onClick={() => setLoading(
true
)}
disabled={loading}>
{
" "
}
{loading ?
"Loading..."
:
"Load Data"
}{
" "
}
</Button>
{
" "
}
</div>
{
" "
}
{showSpinner && (
<div className=
"text-center mt-4"
>
{
" "
}
<Spinner animation=
"border"
role=
"status"
>
{
" "
}
<span className=
"visually-hidden"
>Loading...</span>
{
" "
}
</Spinner>
{
" "
}
</div>
)}
{
" "
}
{data.length > 0 && (
<ul className=
"list-group mt-4"
>
{
" "
}
{data.map((item, index) => (
<li key={index} className=
"list-group-item"
>
{
" "
}
{item}
{
" "
}
</li>
))}
{
" "
}
</ul>
)}
{
" "
}
</Container>
);
}
export
default
App;