Navigates? | declarative? | Makes GET, triggers loader | Makes POST, triggers action | No requests |
---|---|---|---|---|
navigates | declarative | <Link to=""> <Form method="get"> |
<Form method="post"> |
<Link to="#..."> |
navigates | imperative | navigate() setSearchParams() |
submit() |
navigate("#") |
stays | declarative | <fetcher.Form method="get"> |
<fetcher.Form method="post"> |
(doesn't make sense) |
s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// root.tsx | |
import { getUserSession, requireUser, logout } from "~/session"; | |
export function loader({ request }) { | |
// use case: know if the user is logged in, no redirect to /login | |
let userSession = await getUserSession(request); | |
let isAuthenticated = userSession.has("userId"); | |
return { isAuthenticated }; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function useIsPendingPathname(to) { | |
let { location } = useTransition(); | |
let { pathname } = useResolvedPath(to); | |
return location?.pathname === pathname; | |
} | |
function useIsSlowTransition(ms = 300) { | |
let transition = useTransition(); | |
let [isSlow, setIsSlow] = useState(false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { AnimatePresence, usePresence } from "framer-motion"; | |
import { classNames } from "~/lib/utils/class-names"; | |
import { useCounter } from "@kyleshevlin/use-common"; | |
import { useCallback } from "react"; | |
const Box = ({ count }: { count: number }) => { | |
const [isPresent, safeToRemove] = usePresence(); | |
const onAnimationEnd = useCallback(() => { | |
if (!isPresent) safeToRemove(); |
OlderNewer