Skip to main content

Web frameworks · Intermediate · 26 min

Build forms in React 19 with actions and useActionState

By Padding · Updated 18 Nov 2026
Node.js 26 · React 19.3.1 · Vite 8.3.8 · checked in Chromium with Playwright 1.65.1

You will build a hall booking form in React 19.3 that sends through a form action, shows the server's field errors next to the right inputs, never submits twice and adds the booking to a list before the server answers.

On this page

React 19 changed how forms work. Instead of an onSubmit handler that calls preventDefault, reads every field from state and juggles a loading flag, you give the form an action: a function that receives the form's data. React runs it inside a transition, tracks whether it is still running, and resets the form when it finishes. Three hooks build on that: useActionState keeps what the action returned (errors, a message, saved data), useFormStatus tells a button deep inside the form that a submission is in flight, and useOptimistic shows the result before the server has confirmed it.

In this tutorial you build a booking form for a community hall. It runs as a plain React app on Vite, with no framework, and talks to a small mock API that you write in Node.js. The API is slow on purpose and rejects some bookings, so you can see every state: sending, refused with field errors, and saved. You finish with a Playwright script that proves the form keeps the reader's input after an error and never sends the same booking twice.

If you want the same ideas on the server, with Next.js server actions writing to a database, the library app series covers them in add and edit books with server actions. Everything here runs in the browser.

Step 1 · Create the project

Create a folder for the demo and install exact versions of React, React DOM, Vite and Vite's React plugin. Pinning the versions means the code below behaves the same for you as it did when this tutorial was written:

Bash
mkdir -p ~/hall-booking-demo
cd ~/hall-booking-demo
cat > package.json <<'JSON'
{
  "name": "hall-booking-demo",
  "private": true,
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build"
  }
}
JSON
npm install react@19.3.1 react-dom@19.3.1
npm install --save-dev vite@8.3.8 @vitejs/plugin-react@6.3.0

Add the Vite config, the HTML page and the entry file. The proxy setting forwards any request to /api from the Vite dev server to the mock API on port 3001, so the browser only ever talks to one address and you avoid CORS settings:

Bash
cat > vite.config.js <<'JS'
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

export default defineConfig({
  plugins: [react()],
  server: {
    proxy: { '/api': 'http://localhost:3001' },
  },
})
JS
cat > index.html <<'HTML'
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Book the community hall</title>
  </head>
  <body>
    <div id="root"></div>
    <script type="module" src="/src/main.jsx"></script>
  </body>
</html>
HTML
mkdir -p src
cat > src/main.jsx <<'JSX'
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import App from './App.jsx'

createRoot(document.getElementById('root')).render(
  <StrictMode>
    <App />
  </StrictMode>,
)
JSX

The project uses plain JavaScript with JSX so the form code stays short. The same hooks work unchanged in TypeScript.

Check it worked

Bash
npm ls react react-dom vite @vitejs/plugin-react

The tree lists react@19.3.1, react-dom@19.3.1, vite@8.3.8 and @vitejs/plugin-react@6.3.0, with no UNMET or invalid lines.

Step 2 · Write a mock booking API

The form needs something to send to. Create server.mjs, a small API built on Node's http module. It keeps bookings in memory, waits 1.5 seconds before every answer to act like a slow mobile connection, and checks each booking:

  • the name must have at least two characters once spaces are trimmed
  • the email must look like an address
  • the date must be today or later, and the hall is closed on Sundays
  • there must be between 1 and 40 guests

When a booking fails, it answers 422 with an errors object keyed by field name. When it succeeds, it answers 201 with the new booking and the full list. GET /api/bookings returns the list and a count of every POST it has received, which the final step uses to prove nothing was sent twice:

Bash
cd ~/hall-booking-demo
cat > server.mjs <<'JS'
import { createServer } from 'node:http'

const bookings = []
let attempts = 0

function validate(input) {
  const errors = {}
  const name = String(input.name ?? '').trim()
  const email = String(input.email ?? '').trim()
  const date = String(input.date ?? '')
  const guests = Number(input.guests)
  const today = new Date().toISOString().slice(0, 10)

  if (name.length < 2) errors.name = 'Enter your full name.'
  if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
    errors.email = 'Enter an email address like name@example.com.'
  }
  if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
    errors.date = 'Choose a date.'
  } else if (date < today) {
    errors.date = 'Choose a date from today onwards.'
  } else if (new Date(`${date}T00:00:00Z`).getUTCDay() === 0) {
    errors.date = 'The hall is closed on Sundays. Choose another day.'
  }
  if (!Number.isInteger(guests) || guests < 1 || guests > 40) {
    errors.guests = 'Enter between 1 and 40 guests.'
  }
  const notes = String(input.notes ?? '').slice(0, 200)
  return { errors, booking: { name, email, date, guests, notes } }
}

function send(res, status, body) {
  res.writeHead(status, { 'Content-Type': 'application/json' })
  res.end(JSON.stringify(body))
}

createServer((req, res) => {
  if (req.url !== '/api/bookings') return send(res, 404, { message: 'Not found' })
  if (req.method === 'GET') return send(res, 200, { bookings, attempts })
  if (req.method !== 'POST') return send(res, 405, { message: 'Method not allowed' })

  let raw = ''
  req.on('data', (chunk) => {
    raw += chunk
  })
  req.on('end', () => {
    attempts += 1
    setTimeout(() => {
      let input
      try {
        input = JSON.parse(raw)
      } catch {
        return send(res, 400, { message: 'The body must be JSON.' })
      }
      const { errors, booking } = validate(input)
      if (Object.keys(errors).length > 0) return send(res, 422, { errors })
      const saved = { id: bookings.length + 1, ...booking }
      bookings.push(saved)
      send(res, 201, { booking: saved, bookings })
    }, 1500)
  })
}).listen(3001, () => console.log('Mock booking API on http://localhost:3001'))
JS

This is a stand-in for whatever back end you really use. The point is the shape of the reply: one message per field, so the form can put each one beside its input. A real API also needs limits on body size, authentication and a database.

Start it in a terminal of its own. It keeps running until you press Ctrl+C:

Bash
cd ~/hall-booking-demo
node server.mjs

Check it worked

In a second terminal, send a booking that breaks every rule:

Bash
curl -s -w '\nHTTP %{http_code}\n' -X POST http://localhost:3001/api/bookings \
  -H 'Content-Type: application/json' \
  -d '{"name":"   ","email":"amina","date":"2020-01-01","guests":"0"}'

After a pause of about a second and a half, you get HTTP 422 and four messages, one each for name, email, date and guests. The name of three spaces fails because the server trims it first, which matters later: the browser's own required check accepts it.

Step 3 · Send the form with an action

Now the React side. Create three files in src/. First, api.js sends the fields as JSON. A 422 is an expected answer with field errors, so it is returned. Anything else that is not a success is thrown, and so is a network failure:

Bash
cd ~/hall-booking-demo
cat > src/api.js <<'JS'
export async function createBooking(fields) {
  const response = await fetch('/api/bookings', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(fields),
  })
  if (!response.ok && response.status !== 422) {
    throw new Error(`Booking service answered ${response.status}`)
  }
  return response.json()
}
JS

Second, SubmitButton.jsx. useFormStatus reports on the form the component sits inside, so it must live in a child component of the <form>, not in the component that renders the form. While a submission is in flight, pending is true, the button is disabled and its label changes:

Bash
cat > src/SubmitButton.jsx <<'JSX'
import { useFormStatus } from 'react-dom'

export default function SubmitButton() {
  const { pending } = useFormStatus()
  return (
    <button type="submit" disabled={pending}>
      {pending ? 'Booking…' : 'Book the hall'}
    </button>
  )
}
JSX

Third, the form itself in App.jsx:

Bash
cat > src/App.jsx <<'JSX'
import { useActionState, useState } from 'react'
import { createBooking } from './api.js'
import SubmitButton from './SubmitButton.jsx'
import './App.css'

const initialState = { bookings: [], errors: {}, message: '', values: {} }
const today = new Date().toISOString().slice(0, 10)

function FieldError({ field, errors }) {
  if (!errors[field]) return null
  return (
    <p id={`${field}-error`} className="field-error">
      {errors[field]}
    </p>
  )
}

export default function App() {
  const [notes, setNotes] = useState('')

  async function bookHall(previous, formData) {
    const values = Object.fromEntries(formData)
    try {
      const result = await createBooking(values)
      if (result.errors) {
        const count = Object.keys(result.errors).length
        return {
          ...previous,
          errors: result.errors,
          values,
          message: `The booking was not made. Fix ${count === 1 ? '1 field' : `${count} fields`} below.`,
        }
      }
      setNotes('')
      return {
        bookings: result.bookings,
        errors: {},
        values: {},
        message: `Booked for ${result.booking.name} on ${result.booking.date}.`,
      }
    } catch {
      return {
        ...previous,
        errors: {},
        values,
        message: 'Could not reach the booking service. Your details are still here, so try again.',
      }
    }
  }

  const [state, formAction, isPending] = useActionState(bookHall, initialState)
  const { errors, values } = state

  // Ties a field to its error message, for screen readers.
  const describedBy = (field) =>
    errors[field] ? { 'aria-invalid': true, 'aria-describedby': `${field}-error` } : {}

  return (
    <main className="booking">
      <h1>Book the community hall</h1>
      <p role="status" className="form-message">
        {state.message}
      </p>

      <form action={formAction} aria-busy={isPending}>
        <div className="field">
          <label htmlFor="name">Full name</label>
          <input id="name" name="name" autoComplete="name" required minLength={2}
            defaultValue={values.name ?? ''} {...describedBy('name')} />
          <FieldError field="name" errors={errors} />
        </div>

        <div className="field">
          <label htmlFor="email">Email</label>
          <input id="email" name="email" type="email" autoComplete="email" required
            defaultValue={values.email ?? ''} {...describedBy('email')} />
          <FieldError field="email" errors={errors} />
        </div>

        <div className="field">
          <label htmlFor="date">Date</label>
          <input id="date" name="date" type="date" min={today} required
            defaultValue={values.date ?? ''} {...describedBy('date')} />
          <FieldError field="date" errors={errors} />
        </div>

        <div className="field">
          <label htmlFor="guests">Number of guests</label>
          <input id="guests" name="guests" type="number" min={1} max={40} required
            defaultValue={values.guests ?? '1'} {...describedBy('guests')} />
          <FieldError field="guests" errors={errors} />
        </div>

        <div className="field">
          <label htmlFor="notes">Notes for the caretaker (optional)</label>
          <textarea id="notes" name="notes" rows={3} maxLength={200}
            value={notes} onChange={(event) => setNotes(event.target.value)}
            aria-describedby="notes-count" />
          <p id="notes-count" className="hint">{notes.length} of 200 characters</p>
        </div>

        <SubmitButton />
      </form>
    </main>
  )
}
JSX
cat > src/App.css <<'CSS'
.booking { max-width: 32rem; margin: 2rem auto; padding: 0 1rem; font-family: system-ui, sans-serif; }
.field { display: grid; gap: 0.25rem; margin-bottom: 1rem; }
.field input, .field textarea { font: inherit; padding: 0.5rem; }
.field [aria-invalid='true'] { border: 2px solid #b3261e; }
.field-error { color: #b3261e; margin: 0; }
.hint { color: #555; margin: 0; font-size: 0.875rem; }
.form-message { min-height: 1.5rem; font-weight: 600; }
button { font: inherit; padding: 0.6rem 1.2rem; }
button:disabled { opacity: 0.6; cursor: progress; }
.bookings { padding-left: 1.2rem; }
.bookings .sending { color: #555; font-style: italic; }
CSS

How the pieces fit:

  • <form action={formAction}> hands the submit to React. React builds a FormData from the named fields and calls your action with it. There is no onSubmit, no preventDefault and no state for each field.
  • useActionState(bookHall, initialState) gives back the latest state, the formAction to put on the form, and isPending. Your action receives the previous state first and the form data second, and whatever it returns becomes the new state. If a second submission arrives while one is running, React queues it and runs them in order. It does not drop it, which is why the button below still matters.
  • After a successful action, React resets every uncontrolled field to its defaultValue. On an error you do not want an empty form, so the action returns the submitted values and each field uses them as its defaultValue. React applies the new defaults before the reset, so the reader's input stays in place.
  • Each error sits in an element with an id, and the field points at it with aria-describedby and sets aria-invalid. When the field gets focus, a screen reader reads something like "Date, invalid entry, The hall is closed on Sundays". The summary line has role="status" and is always in the page, so its new text is announced without moving focus.
  • The required, type="email", min and max attributes keep the browser's own validation. The browser blocks an empty or malformed submit before your action runs, and the server still checks everything, because anyone can send a request without your form.

Build the app once to catch typing mistakes before you open a browser:

Bash
npm run build

Check it worked

The build ends with built in and a time, and lists dist/index.html and a JavaScript file under dist/assets/. A mistake in the JSX stops the build with the file name and line instead.

Step 4 · Run the form and read the errors

Start Vite in a second terminal (the API keeps running in the first):

Bash
cd ~/hall-booking-demo
npm run dev

Use a third terminal to confirm that the proxy reaches the API through Vite's address:

Bash
curl -s http://localhost:5173/api/bookings

The reply is {"bookings":[],"attempts":1}. The one attempt is the bad curl from the API step.

Open http://localhost:5173 in a browser and try these four things:

  1. Press Book the hall with the form empty. The browser highlights the name field with its own message and nothing is sent.
  2. Type three spaces as the name, a valid email, today's date or later on a Sunday and 4 guests, then submit. The button turns grey and reads Booking… for a second and a half.
  3. When the answer arrives, the summary says the booking was not made, the name and date fields get a red border, and a message appears under each. Every value you typed is still there.
  4. Fix the name and choose a Monday. This time the summary reads Booked for, your name and the date, and the form clears.

Check it worked

After step 3, the browser's developer tools show aria-invalid="true" and aria-describedby="date-error" on the date input. Run the curl above again after step 4, and attempts has gone up by exactly two, one for each real submit. The empty submit in step 1 never reached the server.

On a slow or prepaid mobile connection, common across much of Africa and elsewhere, a request can take several seconds. People tap again when nothing seems to happen. The disabled button and the changed label tell them it is working, and the next step adds a visible result before the server even answers.

Step 5 · Show the booking before the server answers

Waiting 1.5 seconds with nothing to look at feels slow. useOptimistic lets you show the booking in the list straight away, marked as sending. When the action finishes, React throws the optimistic version away and shows the real state: the saved booking if it worked, nothing if it was refused.

Replace App.jsx with a version that adds the list. The changes are the useOptimistic import and call, the addOptimistic(values) line at the start of the action, and the <section> after the form:

Bash
cd ~/hall-booking-demo
cat > src/App.jsx <<'JSX'
import { useActionState, useOptimistic, useState } from 'react'
import { createBooking } from './api.js'
import SubmitButton from './SubmitButton.jsx'
import './App.css'

const initialState = { bookings: [], errors: {}, message: '', values: {} }
const today = new Date().toISOString().slice(0, 10)

function FieldError({ field, errors }) {
  if (!errors[field]) return null
  return (
    <p id={`${field}-error`} className="field-error">
      {errors[field]}
    </p>
  )
}

export default function App() {
  const [notes, setNotes] = useState('')

  async function bookHall(previous, formData) {
    const values = Object.fromEntries(formData)
    addOptimistic(values)
    try {
      const result = await createBooking(values)
      if (result.errors) {
        const count = Object.keys(result.errors).length
        return {
          ...previous,
          errors: result.errors,
          values,
          message: `The booking was not made. Fix ${count === 1 ? '1 field' : `${count} fields`} below.`,
        }
      }
      setNotes('')
      return {
        bookings: result.bookings,
        errors: {},
        values: {},
        message: `Booked for ${result.booking.name} on ${result.booking.date}.`,
      }
    } catch {
      return {
        ...previous,
        errors: {},
        values,
        message: 'Could not reach the booking service. Your details are still here, so try again.',
      }
    }
  }

  const [state, formAction, isPending] = useActionState(bookHall, initialState)
  const [shownBookings, addOptimistic] = useOptimistic(
    state.bookings,
    (current, draft) => [...current, { ...draft, id: 'draft', sending: true }],
  )
  const { errors, values } = state

  // Ties a field to its error message, for screen readers.
  const describedBy = (field) =>
    errors[field] ? { 'aria-invalid': true, 'aria-describedby': `${field}-error` } : {}

  return (
    <main className="booking">
      <h1>Book the community hall</h1>
      <p role="status" className="form-message">
        {state.message}
      </p>

      <form action={formAction} aria-busy={isPending}>
        <div className="field">
          <label htmlFor="name">Full name</label>
          <input id="name" name="name" autoComplete="name" required minLength={2}
            defaultValue={values.name ?? ''} {...describedBy('name')} />
          <FieldError field="name" errors={errors} />
        </div>

        <div className="field">
          <label htmlFor="email">Email</label>
          <input id="email" name="email" type="email" autoComplete="email" required
            defaultValue={values.email ?? ''} {...describedBy('email')} />
          <FieldError field="email" errors={errors} />
        </div>

        <div className="field">
          <label htmlFor="date">Date</label>
          <input id="date" name="date" type="date" min={today} required
            defaultValue={values.date ?? ''} {...describedBy('date')} />
          <FieldError field="date" errors={errors} />
        </div>

        <div className="field">
          <label htmlFor="guests">Number of guests</label>
          <input id="guests" name="guests" type="number" min={1} max={40} required
            defaultValue={values.guests ?? '1'} {...describedBy('guests')} />
          <FieldError field="guests" errors={errors} />
        </div>

        <div className="field">
          <label htmlFor="notes">Notes for the caretaker (optional)</label>
          <textarea id="notes" name="notes" rows={3} maxLength={200}
            value={notes} onChange={(event) => setNotes(event.target.value)}
            aria-describedby="notes-count" />
          <p id="notes-count" className="hint">{notes.length} of 200 characters</p>
        </div>

        <SubmitButton />
      </form>

      <section aria-labelledby="bookings-heading">
        <h2 id="bookings-heading">Bookings</h2>
        {shownBookings.length === 0 ? (
          <p>No bookings yet.</p>
        ) : (
          <ul className="bookings">
            {shownBookings.map((booking) => (
              <li key={booking.id} className={booking.sending ? 'sending' : undefined}>
                {booking.name}, {booking.date}, {booking.guests} guests
                {booking.sending && ' (sending…)'}
              </li>
            ))}
          </ul>
        )}
      </section>
    </main>
  )
}
JSX
npm run build

useOptimistic(state.bookings, reducer) returns shownBookings, which equals the real list until you call addOptimistic. The reducer builds the temporary list from the current one and the draft. You may only call addOptimistic while an action or transition is running, and the form action is one, so the first line of bookHall is the right place. Calling it anywhere else makes React warn in the console.

The page starts with an empty list and shows the server's full list after each successful booking. A real app would also load the existing bookings when the page opens.

The optimistic entry has no server ID yet, so it gets the key draft. Only one can exist at a time, because the button is disabled while a booking is in flight.

Check it worked

Vite reloads the page when the file changes. Submit a valid booking for a Monday. The list shows your booking in grey italics with (sending…) at once, then, about a second and a half later, the same line in normal text. Now submit a Sunday. The grey line appears and then disappears when the server refuses it, and the date error shows under the field. Nothing in the list needed to be undone by hand.

Step 6 · Choose controlled or uncontrolled fields

Look at the two kinds of field you have now.

The name, email, date and guests inputs are uncontrolled. The browser holds their values. React sets a starting value with defaultValue, reads the values once through FormData when the form is sent, and resets them after a success. You wrote no useState and no onChange for them, and React does not re-render while you type.

The notes box is controlled. Its value comes from React state, and every key press goes through onChange into setNotes. That costs a render per key press, and React does not reset it for you, which is why the action calls setNotes('') after a success. It earns its place here because the counter under the box has to change as you type.

A rule of thumb that works for most forms:

  • Use uncontrolled fields when you only need the value on submit. With actions this is the default, and it keeps forms short.
  • Use a controlled field when the screen must react to every key press: a character counter, a live preview, a field that formats itself (a phone number with spaces), or one field whose options depend on another.
  • Do not mix the two on one input. Setting both value and defaultValue, or switching value from undefined to a string, makes React warn about changing an uncontrolled input to controlled.

For pages read in more than one language, remember that maxLength and notes.length count UTF-16 code units, not visible letters. Most Latin, Yoruba and Swahili text counts as you would expect, but some emoji and combined characters count as two or more.

Check it worked

Type a few words in the notes box and watch the counter rise with each key. Then send a Sunday booking with notes. When the error comes back, the notes are still there (they are in state, which the reset does not touch) and so are the other fields (from defaultValue). After a successful booking all fields are empty and the counter reads 0 of 200 characters.

Step 7 · Prove it with a Playwright check

Clicking through by hand once is fine, but forms break quietly. Write a check that drives a real Chromium browser against the running dev server. Install Playwright and its browser in the project:

Bash
cd ~/hall-booking-demo
npm install --save-dev playwright@1.65.1
npx playwright install chromium

On Linux, if Chromium fails to start with errors about missing libraries, install them once with sudo npx playwright install-deps chromium.

The check fills the form with a Sunday, confirms the button is disabled and the sending line shows, then checks the error, the aria-invalid attribute and the kept name. It submits a Monday and presses Enter in the name field while that is pending, to try to send it twice. Last, it submits an empty form. It counts the API's attempts before and after, so it can prove exactly two requests were sent:

Bash
cat > check.mjs <<'JS'
import { chromium } from 'playwright'
import assert from 'node:assert/strict'

const app = 'http://localhost:5173/'
const api = 'http://localhost:3001/api/bookings'
const stats = async () => (await fetch(api)).json()

// The first matching weekday at least a week from today (0 = Sunday, 1 = Monday).
function nextWeekday(day) {
  const date = new Date()
  date.setUTCDate(date.getUTCDate() + 7)
  while (date.getUTCDay() !== day) date.setUTCDate(date.getUTCDate() + 1)
  return date.toISOString().slice(0, 10)
}

const start = await stats()
const browser = await chromium.launch()
const page = await browser.newPage()
await page.goto(app)
const button = page.locator('button[type=submit]')

// 1. A Sunday: the server refuses it.
await page.fill('#name', 'Amina Okafor')
await page.fill('#email', 'amina@example.com')
await page.fill('#date', nextWeekday(0))
await page.fill('#guests', '12')
await page.fill('#notes', 'Choir rehearsal')
await button.click()
await page.waitForSelector('button[type=submit]:disabled')
await page.getByText('(sending…)').waitFor()
await page.locator('#date-error').waitFor()
assert.match(await page.textContent('#date-error'), /closed on Sundays/)
assert.equal(await page.getAttribute('#date', 'aria-invalid'), 'true')
assert.equal(await page.inputValue('#name'), 'Amina Okafor')
assert.equal(await page.inputValue('#notes'), 'Choir rehearsal')
assert.equal(await page.locator('.bookings li').count(), 0)
console.log('Sunday refused, input kept, error linked to the field')

// 2. A Monday, with an Enter press while the first submit is pending.
await page.fill('#date', nextWeekday(1))
await button.click()
await page.waitForSelector('button[type=submit]:disabled')
await page.press('#name', 'Enter')
await page.waitForSelector('.bookings li.sending', { state: 'detached' })
await page.waitForSelector('button[type=submit]:enabled')
assert.equal(await page.locator('.bookings li').count(), start.bookings.length + 1)
assert.match(await page.textContent('[role=status]'), /Booked for Amina Okafor/)
assert.equal(await page.inputValue('#name'), '')
assert.equal(await page.inputValue('#notes'), '')
assert.equal(await page.getAttribute('#date', 'aria-invalid'), null)
console.log('Monday booked once, form cleared')

// 3. An empty form: the browser stops it before the action runs.
await button.click()
assert.equal(await page.$eval('#name', (el) => el.validity.valueMissing), true)
await page.waitForTimeout(500)

await browser.close()
const end = await stats()
assert.equal(end.attempts - start.attempts, 2)
assert.equal(end.bookings.length - start.bookings.length, 1)
console.log(`Requests sent: ${end.attempts - start.attempts}. Bookings saved: ${end.bookings.length - start.bookings.length}.`)
JS
node check.mjs

Check it worked

The script prints three lines and exits without an error:

Text
Sunday refused, input kept, error linked to the field
Monday booked once, form cleared
Requests sent: 2. Bookings saved: 1.

If the Enter press had sent a second booking, the request count would be 3 and the list would hold two entries. It does not, because a form whose submit button is disabled ignores Enter: the HTML standard calls this implicit submission, and it only fires through an enabled default button. Try removing disabled={pending} from SubmitButton.jsx and running the check again. It fails, which shows the check is testing something real. Put the attribute back afterwards.

Playwright keeps its browsers in a shared cache. If no other project uses them, run npx playwright uninstall in ~/hall-booking-demo before you delete the folder.

When you have finished, stop the dev server and the API with Ctrl+C in their terminals, then remove the demo:

Bash
cd ~
rm -rf ~/hall-booking-demo

Next steps

Need this done for you?

Padding does this work for growing companies, from the first diagnosis to a system that keeps working.

Platform Engineering

Get new tutorials

New tutorials, about twice a month.