React State and Forms
Project workbook · Path 78

Build a small controlled registration form with derived totals, validation and reset behavior.

The case

A fictional workshop form collects a name and 1–4 seats. Each seat costs 15 teaching units. The displayed total is derived from seat state, not stored independently. Submitting valid data shows a local confirmation; it does not reserve real seats or transmit data.

State or ruleValue
Initial nameempty
Initial seats1
Price per seat15
Maximum seats4
Example seats3
STAGE 1

Separate props and state

Props supply values from a parent; state records values that change through interaction. Identify the minimum state needed for the form and derive the total during rendering. Redundant state can drift out of sync. Some provider examples use older class syntax; use the linked current React guidance for this functional-component exercise.

Your task

List name, seats and submission state, then identify derived values.

Required output

State model

Record your result and evidence here or in a separate file.

Review gate

Total is derived from seats × 15.

If the gate is not met

Remove any state field that can be calculated from another one.

STAGE 2

Build controlled inputs

A controlled input displays a value from state and updates that state through an event handler. Numeric form input still needs careful parsing and validation. Keep labels associated with fields and use native form semantics. The interface should communicate errors without relying only on color.

Your task

Implement name and seat inputs with visible labels.

Required output

Form component

Record your result and evidence here or in a separate file.

Review gate

Typing and selecting update the displayed state without uncontrolled-input warnings.

If the gate is not met

Use consistent initial values and explicit event conversion.

STAGE 3

Validate before confirming

Validation should follow the case contract and preserve the entered data so a learner can correct it. Do not present a local mock as a server booking. A submit handler should prevent page navigation for this demonstration and show a confirmation only after the name and seat rules pass.

Your task

Add blank-name and seat-range checks plus a local-only confirmation.

Required output

Submission behavior

Record your result and evidence here or in a separate file.

Review gate

Three seats show 45 units; invalid input cannot produce a success message.

If the gate is not met

Separate validation errors from the confirmation branch.

STAGE 4

Test reset and derived state

Reset is a user-facing behavior, not simply clearing the screen. Restore the initial name, one seat, 15-unit total and no confirmation. Test changing seats after an invalid submit and after a successful one. Keep the displayed result connected to the intended current or submitted state.

Your task

Run the behavior checklist and explain whether confirmation stores a snapshot.

Required output

Interaction evidence

Record your result and evidence here or in a separate file.

Review gate

Reset returns the documented initial state and total remains consistent.

If the gate is not met

Decide whether a confirmation describes current input or the last submitted snapshot.

STAGE 5

Prepare an accessible handoff

Keyboard use, labels and readable errors are part of the component’s behavior. Explain the boundary between this local form and a real booking service. The latter would need server validation, persistence and concurrency handling. Document dependencies actually used and do not claim that the local exercise implements those missing pieces.

Your task

Write a README and check keyboard order and error announcement.

Required output

Component handoff

Record your result and evidence here or in a separate file.

Review gate

No network request or real reservation is implied by the confirmation.

If the gate is not met

Rename the success text to local preview if it could mislead.

Final project

Deliver the component, pure validation helper, interaction checklist and README. Demonstrate invalid submission, valid local confirmation, editing after confirmation and reset.

Critical condition

The total is derived consistently and local confirmation is never represented as a real booking.

CriterionPointsEvidence
Evidence and correctness30Calculations, source use and results match the supplied case; limitations are honest.
Required artifacts30All five stage outputs and the capstone handoff are present and inspectable.
Reasoning and decisions20Choices, assumptions, alternatives and the case-specific critical condition are explained.
Reproducibility10A reviewer can follow the stated steps and distinguish expected from observed results.
Clear communication10Labels, units, structure and evidence references make the work easy to review.

Score at least 80/100, supply every required artifact, and satisfy the path-specific critical condition. Rework missing evidence before marking complete.

Worked reference

With seats=3, total is 3×15=45. Reset sets seats=1 and total becomes 15 automatically. The reference separates pure validation from the UI so the rules can be checked independently, while the actual component still needs browser interaction checks in the learner’s React environment.

Boundaries

This is a local component exercise, not a deployed app, payment flow or reservation backend.