Skip to main content
AIDevOps
  • Learn
  • Learning Paths
  • Practice
  • Open Source
  • Books
  • Engineering

    AI DevOpsThe full map of building and operating AI servicesLLMOpsLLM deployment · evaluation · observabilityHands-on ProjectsBuild AI Agent projects

    Knowledge

    DocsTechnical documentationBlogEngineering articlesPloggerDevelopment log feed

    Validate

    Certification3-level skills certification · coming soon
AI Models
LlamaTutorial|MistralTutorial|GemmaTutorial|DeepSeekTutorial|QwenTutorial
🎨 Frontend
Frontend Intro & RoadmapJavaScriptTypeScript|ReactNext.js|VueNuxt|Electron
🤖 AI Applied Development
Applied AI Intro & RoadmapHugging FaceLangChainLlamaIndexLLMOps|LangGraphMCPMulti-AgentAgent Evaluation
🧠 AI Core
AI Intro & RoadmapML FundamentalsLLM Fundamentals|Python AIC++|PyTorchTensorFlowJAX
🧠 AI Agent Development
Finance AI AgentLLM API ServerStock Investing AgentAIOps AI AgentEducation AI AgentCoding AI Agent
🌱 Spring Cloud
Spring Intro & RoadmapSpring Cloud GatewaySpring BootJava|Spring AISpring SecuritySpring BatchSpring JPA
🐳 DevOps
DevOps Intro & RoadmapLinuxDockerCI/CD|Kubernetes BasicsK8s AdvancedPrometheusGrafana
🧱 Infrastructure
Infrastructure Intro & RoadmapNginxRedis
☁️ Cloud
Cloud Intro & RoadmapAWSGCPAzureNCPCloudflare
📱 Mobile
Mobile Intro & RoadmapKotlinAndroidFlutter
⚙️ Backend
Backend Intro & RoadmapPython BasicsFastAPIDjangoFlask|CGoGinNode.js
💾 Database
DB Intro & RoadmapCore SQLOracleMySQLPostgreSQL|MongoDBVector DB
🧪 Testing
k6JMeternGrinder
AIDevOps

Engineering AI. From Code to Production.
An engineering learning platform for building and operating AI and AI Agents

Learn

  • All Guides
  • Learning Paths
  • AI Tutorial
  • Practice
  • Books

Resources

  • AI DevOps
  • LLMOps
  • Hands-on Projects
  • Docs
  • Blog
  • Plogger
  • Open Source
  • Certification (coming soon)

Start Here

  • AI Core Roadmap
  • AI Applied Development Roadmap
  • Spring Cloud Roadmap
  • DevOps Roadmap
  • Infrastructure Roadmap

 

  • Cloud Roadmap
  • Frontend Roadmap
  • Mobile Roadmap
  • Backend Roadmap
  • Database Roadmap
© 2026 AIDevOps. All rights reserved.
Terms of ServicePrivacy PolicySitemaptestforge.kr
  1. Home
  2. Learn
  3. Frontend
  4. React
Guide to the frontend framework

⚛️ React Complete Guide

Visitors

Build modern UI with React 19 from Meta. Covers the whole of practical React development: Hooks fundamentals, the new Actions-based features, state management strategy, server state fetching, form validation, component design patterns, performance optimization, testing, and accessibility.

  • Intermediate
  • Updated Oct 1, 2026
  • ~7 min read
  • 14 sections
  • 9 code examples
  • Web IDE lab included
⚛️

React Web IDE

Run code in the browser with nothing to install and learn through step-by-step examples.

Open the Web IDE →
SPA web appsNext.js SSRReact Native (mobile)Electron (desktop)

Contents

0 / 17
  1. How to use this guide
  2. Architecture diagrams
  3. Environment setup
  4. Hooks fundamentals
  5. New in React 19
  6. State management strategy
  7. Server state & data fetching
  8. Forms & validation
  9. Component design patterns
  10. Performance optimization
  11. Testing
  12. Accessibility
  13. React design
  14. Operating standards
  15. Verification strategy
  16. Frequently asked questions
  17. Next steps
Contents 17 sections
  1. How to use this guide
  2. Architecture diagrams
  3. Environment setup
  4. Hooks fundamentals
  5. New in React 19
  6. State management strategy
  7. Server state & data fetching
  8. Forms & validation
  9. Component design patterns
  10. Performance optimization
  11. Testing
  12. Accessibility
  13. React design
  14. Operating standards
  15. Verification strategy
  16. Frequently asked questions
  17. Next steps

How to use this guide

How to read it

Understanding React as a real-world workflow

Build modern UI with React 19 from Meta. Covers the whole of practical React development: Hooks fundamentals, the new Actions-based features, state management strategy, server state fetching, form validation, component design patterns, performance optimization, testing, and accessibility. Rather than listing concepts, this guide is organized so you can follow the content in the order you have to make decisions on a real project.

Key perspective

Frontend / app development

Do not stop at drawing the screen: look at state, data requests, routing, accessibility, and the unit of deployment together.

SPA web appsNext.js SSRReact Native (mobile)Electron (desktop)

Architecture diagrams

To make what you read stick, it helps to capture the flow as a picture first. The two diagrams below are reference maps you can keep coming back to while learning React.

Learning flow

Rendering diagram…

Architecture view

Rendering diagram…

Environment setup

When you first open React, the big picture matters more than individual commands. This section starts with the problems the concepts ahead were created to solve.

Choose Next.js if you need server rendering, routing, and SEO, and Vite for a light, fast, pure SPA.
BASH
# Next.js (recommended — includes SSR/Server Components)
npx create-next-app@latest my-app --typescript --tailwind --app

# Vite (SPA)
npm create vite@latest my-app -- --template react-ts
cd my-app && npm install && npm run dev

# To install just the React 19 core
npm install react@19 react-dom@19

Hooks fundamentals

Here you look at Hooks fundamentals alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

useState, useEffect, useCallback, useMemo, useRef — there are only two rules of Hooks. Call them only at the top level, and only inside components/custom hooks.
TSX
import { useState, useEffect, useCallback } from 'react';

function useFetch<T>(url: string) {
  const [data, setData]   = useState<T | null>(null);
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    let cancelled = false;
    fetch(url)
      .then(r => r.json())
      .then(d => { if (!cancelled) setData(d); })
      .finally(() => { if (!cancelled) setLoading(false); });
    return () => { cancelled = true; };
  }, [url]);

  return { data, loading };
}

Tip

  • Never call a Hook inside a condition or loop — breaking this rule scrambles the state slots
  • Manage the useEffect dependency array with the ESLint exhaustive-deps rule
  • Remember that the cleanup function runs not only on unmount but every time the dependencies change
  • If several pieces of state always change together, grouping them in useReducer beats several useState calls

New in React 19

Here you look at New in React 19 alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

React 19 redefined how form submission and asynchronous work are handled around Actions. useActionState, useOptimistic, and use() are the core.
TSX
import { useActionState, useOptimistic, use } from 'react';

// Manages the form submission state (pending/error) automatically
function ProfileForm({ updateName }: {
  updateName: (prev: { error?: string }, formData: FormData) => Promise<{ error?: string }>;
}) {
  const [state, formAction, isPending] = useActionState(updateName, {});

  return (
    <form action={formAction}>
      <input name="name" />
      <button type="submit" disabled={isPending}>Save</button>
      {state.error && <p>{state.error}</p>}
    </form>
  );
}

// Update the UI optimistically before the server responds
function LikeButton({ likes, addLike }: { likes: number; addLike: () => Promise<void> }) {
  const [optimisticLikes, addOptimisticLike] = useOptimistic(likes, (state) => state + 1);
  return (
    <button onClick={async () => { addOptimisticLike(); await addLike(); }}>
      Like {optimisticLikes}
    </button>
  );
}

// Read a Promise conditionally (works with Suspense)
function Comments({ commentsPromise }: { commentsPromise: Promise<{ id: string; text: string }[]> }) {
  const comments = use(commentsPromise);
  return <ul>{comments.map(c => <li key={c.id}>{c.text}</li>)}</ul>;
}
APIPurpose
useActionStateManages the pending/error state of a form action automatically
useOptimisticUpdates the UI optimistically before the server responds
use()Reads Promises and Context conditionally and integrates with Suspense automatically
React CompilerAn optimization that inserts memo/useMemo/useCallback automatically at build time

State management strategy

Here you look at State management strategy alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

The rule for deciding where state lives matters more than the shape of the component tree. The default is local state; lift it up when several components share it; use Context when the whole tree needs it; and manage app-wide client state with a dedicated library.
store.tsTYPESCRIPT
import { create } from 'zustand';

interface BearStore {
  count: number;
  inc: () => void;
  dec: () => void;
}

export const useBearStore = create<BearStore>((set) => ({
  count: 0,
  inc: () => set((s) => ({ count: s.count + 1 })),
  dec: () => set((s) => ({ count: s.count - 1 })),
}));
ScopeToolGood fit
Component localuseState / useReducerState used only by the component and its children
Shared by part of the treeContext + useReducerValues that rarely change, such as the theme or the signed-in user
App-wide client stateZustandUI state, form wizard steps, and so on (minimal boilerplate)
Large/complex domainsRedux ToolkitLarge teams that need action history tracking and time-travel debugging
Data from the serverTanStack Query / SWRAll API data that needs caching, revalidation, and optimistic updates

Tip

Do not copy data fetched from the server into a client state library — use the server state management in the next section

Server state & data fetching

Here you look at Server state & data fetching alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

Data from the server has different problems from client state (caching, revalidation, deduplicating requests, optimistic updates), so it is safer to handle it with a dedicated library such as TanStack Query.
TSX
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';

function TodoList() {
  const queryClient = useQueryClient();

  const { data, isPending, error } = useQuery({
    queryKey: ['todos'],
    queryFn: () => fetch('/api/todos').then(r => r.json()),
    staleTime: 30_000,
  });

  const addTodo = useMutation({
    mutationFn: (title: string) =>
      fetch('/api/todos', { method: 'POST', body: JSON.stringify({ title }) }),
    onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
  });

  if (isPending) return <p>Loading...</p>;
  if (error) return <p>Failed to load</p>;

  return (
    <ul>
      {data.map((todo: { id: string; title: string }) => (
        <li key={todo.id}>{todo.title}</li>
      ))}
    </ul>
  );
}

Tip

  • A staleTime of 0 refetches on every focus change, so tune it to the nature of the data
  • Updating the cache directly with setQueryData instead of invalidateQueries makes optimistic updates faster

Forms & validation

Here you look at Forms & validation alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

The React Hook Form + Zod combination is the standard for type-safe form validation. It also performs well, because each input re-renders only its own field rather than the whole form.
TSX
import { useForm } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import { z } from 'zod';

const schema = z.object({
  email: z.string().email('Enter a valid email address'),
  password: z.string().min(8, 'Enter at least 8 characters'),
});
type FormValues = z.infer<typeof schema>;

function LoginForm() {
  const { register, handleSubmit, formState: { errors, isSubmitting } } =
    useForm<FormValues>({ resolver: zodResolver(schema) });

  const onSubmit = async (values: FormValues) => {
    await fetch('/api/login', { method: 'POST', body: JSON.stringify(values) });
  };

  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      <input {...register('email')} />
      {errors.email && <p>{errors.email.message}</p>}
      <input type="password" {...register('password')} />
      {errors.password && <p>{errors.password.message}</p>}
      <button type="submit" disabled={isSubmitting}>Sign in</button>
    </form>
  );
}

Component design patterns

Here you look at Component design patterns alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

As components grow, pull logic out into custom hooks, isolate errors with an Error Boundary, and raise cohesion for sets of components that work together with a Compound Component.
TSX
import { Component, createContext, useContext, useState, type ReactNode } from 'react';

// Error Boundary — isolates errors in a subtree so they do not take down the whole app
class ErrorBoundary extends Component<{ fallback: ReactNode; children: ReactNode }, { hasError: boolean }> {
  state = { hasError: false };
  static getDerivedStateFromError() { return { hasError: true }; }
  componentDidCatch(error: unknown) { console.error(error); }
  render() {
    return this.state.hasError ? this.props.fallback : this.props.children;
  }
}

// Compound Component — shares internal state through Context
const TabsContext = createContext<{ active: string; setActive: (id: string) => void } | null>(null);

function Tabs({ defaultTab, children }: { defaultTab: string; children: ReactNode }) {
  const [active, setActive] = useState(defaultTab);
  return <TabsContext.Provider value={{ active, setActive }}>{children}</TabsContext.Provider>;
}
Tabs.Tab = function Tab({ id, children }: { id: string; children: ReactNode }) {
  const ctx = useContext(TabsContext)!;
  return <button onClick={() => ctx.setActive(id)} aria-selected={ctx.active === id}>{children}</button>;
};

Performance optimization

Here you look at Performance optimization alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

From React 19 on, the React Compiler inserts memo/useMemo/useCallback automatically at build time. You still need to understand the principles to judge the cases the compiler misses.
TSX
import { memo, useMemo, useCallback } from 'react';

// Prevent unnecessary re-renders
const ListItem = memo(({ item }: { item: Item }) => (
  <div>{item.name}</div>
));

function List({ items }: { items: Item[] }) {
  // Cache an expensive computation
  const sorted = useMemo(
    () => [...items].sort((a, b) => a.name.localeCompare(b.name)),
    [items]
  );
  // Cache the handler
  const handleClick = useCallback((id: string) => {
    console.log(id);
  }, []);
  return sorted.map(item => <ListItem key={item.id} item={item} />);
}

Tip

  • With the React Compiler on, you no longer need to write most memo/useCallback yourself, but breaking the rules of Hooks disables the optimization
  • Most re-render problems are not a lack of memo but a state placement problem — push state down only as far as it is needed
  • Use a stable id for list keys instead of the index
  • Measure the real bottleneck with the React DevTools Profiler before optimizing

Testing

Here you look at Testing alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

With Vitest + React Testing Library, test from the standpoint of "the screen the user sees". Verify behavior, not implementation details.
Counter.test.tsxTSX
import { render, screen, fireEvent } from '@testing-library/react';
import { describe, it, expect } from 'vitest';
import { Counter } from './Counter';

describe('Counter', () => {
  it('increments the value when clicked', () => {
    render(<Counter />);
    const button = screen.getByRole('button', { name: /count/i });
    fireEvent.click(button);
    expect(screen.getByText('1')).toBeInTheDocument();
  });
});

Tip

  • Preferring getByRole/getByLabelText over getByTestId catches accessibility problems along the way
  • Handle API mocking at the network layer with MSW (Mock Service Worker)

Accessibility

This section covers Accessibility from a practical perspective. Instead of memorizing the concept, focus on the situations in which you would reach for it.

Accessibility is not a feature to add later; simply using semantic HTML solves most of it.

Tip

  • Use semantic tags such as button, nav, main, and header instead of div/span
  • Always give images a meaningful alt (alt="" if decorative)
  • For custom dropdowns/modals you have to take care of role, aria-expanded, aria-modal, and the focus trap yourself
  • Check with Tab/Shift+Tab that the whole flow works with the keyboard alone
  • Keep color contrast at 4.5:1 or higher, the WCAG AA standard

React practical design

React practical design is a point where the options diverge. Using the table to compare what each approach is for and how it differs in operation makes later decisions much easier.

In React, data flow design matters more than the component tree. Separate server state, client state, and form state, and keep component responsibilities small.
Decision pointQuestion to askPractical guideline
BoundariesWhich parts of the React code are most likely to change?Separate input/output, configuration, external integrations, and the core rules.
StateWhere is state created and where does it go away?Make the owner and lifecycle of state visible in the code.
FailureWhat does the caller receive on failure?Decide the timeout, fallback, and error contract first.

React operating standards

This section covers React operating standards from a practical perspective. Instead of memorizing the concept, focus on the situations in which you would reach for it.

Rendering performance is affected more by unnecessary state placement and waterfalls than by memo. Design the Suspense/loading/error states.

Tip

  • state ownership
  • server state cache
  • error boundary
  • a11y tests

React verification strategy

React verification strategy is a point where the options diverge. Using the table to compare what each approach is for and how it differs in operation makes later decisions much easier.

Tests based on user scenarios and accessibility tests are the core.
Quality axisHow to verifyDefinition of done
CorrectnessAutomate the normal/failure cases.The core scenarios pass reproducibly.
Regression preventionWhen fixing a bug, leave the same case behind as a test.The same failure is not deployed again.
OperabilityCheck the logs, metrics, and alerts.There is a path for tracing the cause when a problem occurs.

React: frequently asked questions

When should I use useEffect and when should I not?

useEffect is for synchronizing with an external system after rendering: setting up subscriptions, timers, and browser API calls. Values that can be computed from other state, and logic that responds to an event, belong in the render calculation or an event handler, not in useEffect. That avoids unnecessary re-renders and bugs.

Do I have to use a state management library?

Not from the start. Begin with component state and props, plus Context where needed, and manage data fetched from the server with a data fetching library that handles caching and refetching. Introducing a state management library when client state shared across screens gets complicated is not too late.

Why do list items need a key?

React uses the key to work out which items were added, removed, or reordered compared with the previous render. Using the array index as the key can attach input values or state to the wrong item when the order changes, so use a unique ID from the data.

Next steps

This section covers Next steps from a practical perspective. Instead of memorizing the concept, focus on the situations in which you would reach for it.

🚀
Finished the component fundamentals?

Building production-grade React applications — server rendering, the App Router, server actions, ISR, and more — continues in the Next.js guide. If you need a large, type-safe codebase, see the TypeScript guide, and if you want to firm up the language basics, the JavaScript guide.

Related guides: Next.js guide · TypeScript guide · JavaScript guide · Vue guide
← Previous guideTypeScriptNext guide →Next.js