Alan_szt
Alan_szt
TtRPC
Created by Alan_szt on 7/18/2024 in #❓-help
How can I set a Cookie from the server (for the login)?
No description
4 replies
TtRPC
Created by Alan_szt on 7/18/2024 in #❓-help
How to get access to the types generated by the server in the frontend (React)?
In this example, how do you replace data: any to the correct type?
import { trpc } from "../utils/trpc";

type Props = {
onSuccess: (data: any) => void;
};
export function CreateWorker(props: Props) {
const createWorkerMutation = trpc.createWorker.useMutation();

const handleCreateWorker = () => {
createWorkerMutation.mutate(
{ data: "hello" },
{
onSuccess: (data) => props.onSuccess(data),
}
);
};
return <button onClick={handleCreateWorker}>create</button>;
}
import { trpc } from "../utils/trpc";

type Props = {
onSuccess: (data: any) => void;
};
export function CreateWorker(props: Props) {
const createWorkerMutation = trpc.createWorker.useMutation();

const handleCreateWorker = () => {
createWorkerMutation.mutate(
{ data: "hello" },
{
onSuccess: (data) => props.onSuccess(data),
}
);
};
return <button onClick={handleCreateWorker}>create</button>;
}
3 replies