Replies: 3 comments
-
Here's a simple example. It's hard to know your intended use case, since you're mixing export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData();
return json({ success: true, ...Object.fromEntries(formData) });
}
export default function Index() {
const fetcher = useFetcher<typeof action>();
return (
<div style={{ fontFamily: 'system-ui, sans-serif', lineHeight: '1.8' }}>
<h1>Welcome to Remix</h1>
<fetcher.Form method="post">
<input type="text" name="name" value="kiliman" />
<button>Submit</button>
</fetcher.Form>
<pre>{JSON.stringify(fetcher.data, null, 2)}</pre>
</div>
);
} ⚡️ StackBlitz https://stackblitz.com/edit/remix-run-remix-krqmtg?file=app%2Froutes%2F_index.tsx |
Beta Was this translation helpful? Give feedback.
-
Thanks for your help I think I finally figure my code out, I was able to use native code to do what I need to do. I think it was due to incorrect mix of codes of |
Beta Was this translation helpful? Give feedback.
-
I have ParentRoute Wizard.tsx
const post = await request.json();
when error is thrown from action page goes blank with error element shown at the bottom but even if url is /createPost/summary |
Beta Was this translation helpful? Give feedback.
-
I tried using the
useActionData
but it always gets undefined I tried searching for the problem and I see a closed discussion about this, that you must useconst fetcher = useFetcher(); fetcher.data <-- contains the result
however on my side it is always undefined.My action function is living on the same file / route. What I am trying to do is to submit a
react-hook-form
with an file uploader child component that will read the contents of the file and that gets return on the action that I need to use on the same route.What am I missing in the setup? It actually has more components into it.
Beta Was this translation helpful? Give feedback.
All reactions