Skip to content

Commit

Permalink
Remove NewsletterActionData type (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeiscontent authored Nov 13, 2024
1 parent 9a43cbb commit 7bae15a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
11 changes: 0 additions & 11 deletions app/routes/[_]actions.newsletter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,3 @@ export const action = async ({ request }: ActionFunctionArgs) => {

return { error: null, ok: true };
};

// This is less than ideal, but adding so we can remove SerializeFrom
export type NewsletterActionData =
| {
error: string;
ok: boolean;
}
| {
error: any;
ok: boolean;
};
6 changes: 3 additions & 3 deletions app/ui/subscribe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useFetcher } from "react-router";
import type { FormProps, FetcherWithComponents } from "react-router";
import { Button, Input } from "./buttons";
import cx from "clsx";
import type { NewsletterActionData } from "~/routes/[_]actions.newsletter";
import type { action } from "~/routes/[_]actions.newsletter";

// TODO: look into if v3_fetcherPersist simplifies this component

Expand Down Expand Up @@ -31,7 +31,7 @@ function Subscribe({
}

function SubscribeProvider({ children }: { children: React.ReactNode }) {
let subscribe = useFetcher<NewsletterActionData>();
let subscribe = useFetcher<typeof action>();
let inputRef = React.useRef<HTMLInputElement>(null);

React.useEffect(() => {
Expand All @@ -48,7 +48,7 @@ function SubscribeProvider({ children }: { children: React.ReactNode }) {
}

const SubscribeContext = React.createContext<null | {
fetcher: FetcherWithComponents<NewsletterActionData>;
fetcher: ReturnType<typeof useFetcher<typeof action>>;
inputRef: React.RefObject<HTMLInputElement>;
}>(null);

Expand Down

0 comments on commit 7bae15a

Please sign in to comment.