Skip to content

It showcases how React 19's new hooks can improve form handling, user experience, and state management compared to traditional approaches.

Notifications You must be signed in to change notification settings

hankadev/react19-demo

Repository files navigation

React 19 Demo

🚀 Live Demo: react19-demo-one.vercel.app

Overview

This project demonstrates the new features and hooks introduced in React 19 through a practical "Remember it" reminder application. It showcases how React 19's new hooks can improve form handling, user experience, and state management compared to traditional approaches.

What This Project Demonstrates

React 19 Features Showcased

  1. useActionState Hook - Simplifies form handling with built-in pending states and error management
  2. useTransition Hook - Provides smooth UI transitions during state updates
  3. useOptimistic Hook - Enables optimistic UI updates for better perceived performance
  4. Automatic Head Management - Direct placement of <title> and <meta> tags in components

Interactive Comparison

The application provides a side-by-side comparison showing:

  • Left Panel: Interactive form implementations using different approaches
  • Right Panel: Live code preview of the current implementation
  • Navigation: Switch between different React patterns (Old vs React 19 approaches)

Form Implementations Compared

  • Old Form: Traditional React form handling with manual state management
  • useTransition: Enhanced UX with transition states during async operations
  • useActionState: Streamlined form actions with built-in error and pending states
  • useOptimistic: Immediate UI feedback with optimistic updates

Features

  • 📝 Create and manage reminders
  • 🔄 Compare different React patterns side-by-side
  • 💻 Live code preview with syntax highlighting
  • 📱 Responsive design (2-column layout on desktop, single column on mobile)
  • ⚡ Simulated async operations to demonstrate loading states
  • 🎯 Error handling demonstrations
  • 🔍 SEO-optimized with dynamic page titles and meta tags

Tech Stack

  • React 19.1.0 - Latest React version with new hooks
  • Vite - Fast build tool and dev server
  • React Router - Client-side routing
  • React Syntax Highlighter - Code preview functionality
  • TypeScript - Type safety for form components

Getting Started

Prerequisites

  • Node.js (version 18 or higher)
  • npm, yarn, or pnpm

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd react19-demo
  2. Install dependencies:

    npm install
  3. Start the development server:

    npm run dev
  4. Open your browser and navigate to http://localhost:5173

Available Scripts

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm run preview - Preview production build
  • npm run lint - Run ESLint
  • npm run format - Format code with Prettier

Project Structure

src/
├── components/
│   ├── form-old/           # Traditional form implementation
│   ├── form-useTransition/ # useTransition implementation
│   ├── form-useActionState/# useActionState implementation
│   ├── CodePreview/        # Syntax highlighted code display
│   ├── Navigation/         # App navigation
│   └── RemindersList/      # Display reminders
├── pages/                  # Route components
└── App.jsx                 # Main application component

Learning Objectives

By exploring this demo, you'll learn:

  • How React 19's new hooks simplify common patterns
  • The differences between traditional and modern React approaches
  • When to use useActionState vs useTransition vs useOptimistic
  • Best practices for form handling in React 19
  • How to implement optimistic UI updates
  • Managing loading and error states effectively
  • React 19's automatic head management for SEO optimization

Contributing

Feel free to open issues or submit pull requests to improve this demo!

License

This project is open source and available under the MIT License.

About

It showcases how React 19's new hooks can improve form handling, user experience, and state management compared to traditional approaches.

Resources

Stars

Watchers

Forks