Download Amazon-clone/src/App.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 2.01 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/Amazon-clone/src/App.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/Amazon-clone/src/App.js
-
curl -L -o App.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/Amazon-clone/src/App.js
2.01 kB
| import "./App.css"; | |
| import { useState, useEffect } from "react"; | |
| import { Routes, Route, Navigate, BrowserRouter } from "react-router-dom"; | |
| import Home from "./Components/Home"; | |
| import Lists from "./Components/Lists"; | |
| import Signin from "./Components/Signin"; | |
| import Signup from "./Components/Signup"; | |
| import Load from "./imgs/spin.gif"; | |
| import { app } from "./Firebase"; | |
| import { getAuth, onAuthStateChanged } from "firebase/auth"; | |
| import ProductPage from "./Components/ProductPage"; | |
| import CartSection from "./Components/CartSection"; | |
| import Payment from "./Components/Payment"; | |
| import Profile from "./Components/Profile"; | |
| import Orders from "./Components/Orders"; | |
| import Error from "./Components/Error"; | |
| const auth = getAuth(app); | |
| function App() { | |
| const [user, setUser] = useState(null); | |
| const [loading, setLoading] = useState(true); | |
| useEffect(() => { | |
| onAuthStateChanged(auth, (user) => { | |
| if (user) { | |
| setUser(user); | |
| } else { | |
| setUser(null); | |
| } | |
| setLoading(false); | |
| }); | |
| }, []); | |
| if (loading) { | |
| return ( | |
| <> | |
| <div className="loading"> | |
| <img src={Load} className="loading-img" /> | |
| </div> | |
| </> | |
| ); | |
| } | |
| return ( | |
| <BrowserRouter> | |
| <Routes> | |
| <Route path="/" element={user ? <Navigate to="/home" /> : <Signin />} /> | |
| <Route path="/signup" element={user ? <Navigate to="/home" /> : <Signup />} /> | |
| {user && ( | |
| <> | |
| <Route path="/home" element={<Home />} /> | |
| <Route path="/wishlists" element={<Lists />} /> | |
| <Route path="/cart" element={<CartSection />} /> | |
| <Route path="/payment" element={<Payment />} /> | |
| <Route path="/orders" element={<Orders />} /> | |
| <Route path="/account" element={<Profile />} /> | |
| <Route path="/product/:id" element={<ProductPage />} /> | |
| <Route path="*" element={<Error/>} /> | |
| </> | |
| )} | |
| </Routes> | |
| </BrowserRouter> | |
| ); | |
| } | |
| export default App; | |