scrimba
Learn React Router
Actions
useActionData
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

AboutCommentsNotes
useActionData
Expand for more info
Login.jsx
run
preview
console
import React from "react"
import { Form } from "react-router-dom"

async function fakeLoginUser(creds) {
if (creds.email === "b@b.com" && creds.password === "p123") {
return "User is logged in!"
}
throw new Error("Couldn't log the user in")
}

export async function action({ request }) {
const formData = await request.formData()
const email = formData.get("email")
const password = formData.get("password")
}

export default function Login() {
return (
<Form method="post" replace>
<h2>Login</h2>
<input
type="email"
name="email"
placeholder="Email address"
/>
<br />
<input
type="password"
name="password"
placeholder="Password"
/>
<br />
<button>Log in</button>
</Form>
)
}
Console
/login
-4:24