fix: race condition while setting state

This commit is contained in:
Bereket Engida
2024-09-06 12:50:05 +03:00
parent b808804e0e
commit 1d12ff57cf
3 changed files with 7 additions and 22 deletions

View File

@@ -456,18 +456,5 @@ export const contents: Content[] = [
href: "/docs/plugins/bearer",
},
],
},
{
title: "Guides",
Icon: () => (
<svg xmlns="http://www.w3.org/2000/svg" width="1.4em" height="1.4em" viewBox="0 0 24 24"><path fill="currentColor" d="M5.616 20q-.691 0-1.153-.462T4 18.384V5.616q0-.691.463-1.153T5.616 4h12.769q.69 0 1.153.463T20 5.616v12.769q0 .69-.462 1.153T18.384 20zM12.5 5v5.414q0 .242.202.36t.414-.012l.975-.597q.192-.13.409-.13t.41.13l.974.597q.212.13.414.012t.202-.36V5z"></path></svg>
),
list: [{
title: "Setting up Login with Github",
href: "/docs/guides/github-login",
icon: () => (
<svg xmlns="http://www.w3.org/2000/svg" width="1.2em" height="1.2em" viewBox="0 0 24 24"><path fill="currentColor" d="M8 17.175V6.825q0-.425.3-.713t.7-.287q.125 0 .263.037t.262.113l8.15 5.175q.225.15.338.375t.112.475t-.112.475t-.338.375l-8.15 5.175q-.125.075-.262.113T9 18.175q-.4 0-.7-.288t-.3-.712"></path></svg>
)
}]
}
];

View File

@@ -2,11 +2,7 @@
import { Button } from "@/components/ui/button";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
Card, CardContent, CardDescription, CardHeader, CardTitle,
} from "@/components/ui/card";
import { Checkbox } from "@/components/ui/checkbox";
import { Input } from "@/components/ui/input";
@@ -25,9 +21,9 @@ export default function Page() {
const [password, setPassword] = useState("");
const [rememberMe, setRememberMe] = useState(false);
const router = useRouter();
return (
<div className="h-[50rem] w-full dark:bg-black bg-white dark:bg-grid-white/[0.2] bg-grid-black/[0.2] relative flex items-center justify-center">
<div className="absolute pointer-events-none inset-0 flex items-center justify-center dark:bg-black bg-white [mask-image:radial-gradient(ellipse_at_center,transparent_20%,black)]"></div>
<Card className="mx-auto max-w-sm z-50">
<CardHeader>
@@ -170,4 +166,4 @@ export default function Page() {
</Card>
</div>
);
}
}

View File

@@ -86,8 +86,10 @@ export function createDynamicPathProxy<T extends Record<string, any>>(
if (!matches) return;
const signal = atoms[matches.signal];
if (!signal) return;
//@ts-expect-error
signal.set(!signal.get());
setTimeout(() => {
//@ts-expect-error
signal.set(!signal.get());
}, 0);
},
});
},