diff --git a/Dockerfile b/Dockerfile index bab946292..cf45febdc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM amazonlinux:2023 # Install Git and Node.js (Amazon Linux 2023 uses the DNF package manager) RUN dnf install -y git \ - && curl -sL https://rpm.nodesource.com/setup_22.x | bash - \ + && curl -sL https://rpm.nodesource.com/setup_24.x | bash - \ && dnf install -y nodejs \ && dnf clean all diff --git a/_reference/REACT_19_FEATURES_GUIDE.md b/_reference/REACT_19_FEATURES_GUIDE.md new file mode 100644 index 000000000..37615f70d --- /dev/null +++ b/_reference/REACT_19_FEATURES_GUIDE.md @@ -0,0 +1,468 @@ +# React 19 Features Guide + +## Overview +This guide covers the new React 19 features available in our codebase and provides practical examples for implementing them. + +--- + +## 1. New Hooks for Forms + +### `useFormStatus` - Track Form Submission State + +**What it does:** Provides access to the current form's submission status without manual state management. + +**Use Case:** Show loading states on submit buttons, disable inputs during submission. + +**Example:** +```jsx +import { useFormStatus } from 'react'; + +function SubmitButton() { + const { pending } = useFormStatus(); + + return ( + + ); +} + +function JobForm({ onSave }) { + return ( +
+ + + + ); +} +``` + +**Benefits:** +- No manual `useState` for loading states +- Automatic re-renders when form status changes +- Better separation of concerns (button doesn't need form state) + +--- + +### `useOptimistic` - Instant UI Updates + +**What it does:** Updates UI immediately while async operations complete in the background. + +**Use Case:** Comments, notes, status updates - anything where you want instant feedback. + +**Example:** +```jsx +import { useState, useOptimistic } from 'react'; + +function JobNotes({ jobId, initialNotes }) { + const [notes, setNotes] = useState(initialNotes); + const [optimisticNotes, addOptimisticNote] = useOptimistic( + notes, + (current, newNote) => [...current, newNote] + ); + + async function handleAddNote(formData) { + const text = formData.get('note'); + const tempNote = { id: Date.now(), text, pending: true }; + + // Show immediately + addOptimisticNote(tempNote); + + // Save to server + const saved = await saveNote(jobId, text); + setNotes([...notes, saved]); + } + + return ( +
+