fix flash

This commit is contained in:
Paul Miller
2023-02-21 11:13:22 -06:00
parent 0393759239
commit b251663a0a
4 changed files with 25 additions and 26 deletions

View File

@@ -1,9 +1,8 @@
import { Routes, Route } from "react-router-dom"; import { Routes, Route } from "react-router-dom";
import { AnimatePresence } from "framer-motion";
import Home from "./Home";
import Receive from "./Receive";
import Join from "./Join"; import Join from "./Join";
import Layout from "./components/Layout";
function App() { function App() {
return ( return (
<div className="App"> <div className="App">
@@ -12,7 +11,9 @@ function App() {
<Routes> <Routes>
{/* <Route path="/" element={<Home />} /> */} {/* <Route path="/" element={<Home />} /> */}
<Route path="/" element={<Join />} /> <Route path="/" element={<Layout />}>
<Route index element={<Join />} />
</Route>
</Routes> </Routes>
</div> </div>
); );

View File

@@ -1,13 +1,11 @@
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { redirect } from "react-router-dom";
import button from "./components/button"
import WaitlistForm from "./components/WaitlistForm"; import WaitlistForm from "./components/WaitlistForm";
import { WaitlistAlreadyIn } from "./components/WaitlistAlreadyIn"; import { WaitlistAlreadyIn } from "./components/WaitlistAlreadyIn";
export default function Join() { export default function Join() {
// On load, check if the user is already on the waitlist // On load, check if the user is already on the waitlist
const [waitlisted, setWaitlisted] = useState(false); const [waitlisted, setWaitlisted] = useState(false);
const [waitlistId, setWaitlistId] = useState(localStorage.getItem('waitlist_id') || ""); const [waitlistId] = useState(localStorage.getItem('waitlist_id') || "");
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
// Fetch the waitlist status from the backend // Fetch the waitlist status from the backend
@@ -17,18 +15,17 @@ export default function Join() {
if (res.status === 200) { if (res.status === 200) {
setWaitlisted(true); setWaitlisted(true);
} }
setLoading(false);
}) })
} else {
setLoading(false);
} }
setLoading(false);
}, [waitlistId]); }, [waitlistId]);
return ( return (
<div className="safe-top safe-left safe-right safe-bottom"> <>
<div className="disable-scrollbars max-h-screen h-full overflow-y-scroll mx-4"> {loading ? null : waitlisted ? <WaitlistAlreadyIn /> : <WaitlistForm />}
{waitlisted && !loading ? <WaitlistAlreadyIn /> : !loading ? <WaitlistForm /> : null} </>
</div>
</div >
) )
} }

View File

@@ -0,0 +1,9 @@
import { Outlet } from "react-router-dom";
export default function Layout() {
return (<div className="safe-top safe-left safe-right safe-bottom">
<div className="disable-scrollbars max-h-screen h-full overflow-y-scroll">
<Outlet />
</div>
</div >)
}

View File

@@ -1,19 +1,11 @@
import React from 'react' import React from 'react'
import ReactDOM from 'react-dom/client' import ReactDOM from 'react-dom/client'
import { createBrowserRouter, RouterProvider } from 'react-router-dom' import { BrowserRouter } from 'react-router-dom'
import App from './App' import App from './App'
import './index.css' import './index.css'
const router = createBrowserRouter([
{
path: "/",
element: <App />,
},
]);
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode> <BrowserRouter>
<RouterProvider router={router} /> <App />
{/* <App /> */} </BrowserRouter>
</React.StrictMode>,
) )