Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue: add the loading page #82

Open
shinevue opened this issue Aug 24, 2024 · 2 comments
Open

Issue: add the loading page #82

shinevue opened this issue Aug 24, 2024 · 2 comments

Comments

@shinevue
Copy link
Member

There isn't loading component when the page is rendered.

@BlackGhost2693
Copy link
Contributor

import React, { useState, useEffect } from 'react';
import Loading from './Loading';

function App() {
const [loading, setLoading] = useState(true);
const [data, setData] = useState(null);

useEffect(() => {
    // Simulate data fetching
    setTimeout(() => {
        // Here you would fetch your data from an API
        setData("Hello, this is your data!");
        setLoading(false);
    }, 2000); // Simulate a 2-second load time
}, []);

if (loading) {
    return <Loading />;
}

return (
    <div className="App">
        <h1>Data Loaded</h1>
        <p>{data}</p>
    </div>
);

}

export default App;

@7CodeWizard
Copy link

import React, { useState, useEffect } from 'react';
import LoadingSpinner from './LoadingSpinner'; // Import the loading spinner

const App = () => {
const [loading, setLoading] = useState(true);

useEffect(() => {
// Simulate an API call
const timer = setTimeout(() => {
setLoading(false);
}, 3000); // 3-second loading

return () => clearTimeout(timer);

}, []);

return (


{loading ? (

) : (

Content Loaded!


)}

);
};

export default App;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants