Getting Started with React
Set up your tooling, understand core concepts, and ship your first interactive component in under an hour.
Why React?
React pairs a tiny API surface with a huge ecosystem. You describe what the UI should look like for a given state and React takes care of keeping the DOM in sync. That means fewer imperative updates and more predictable interfaces.
Install the Tooling
- Install the current LTS version of Node.js.
- Run
npm create vite@latest my-react-app -- --template react-tsto scaffold a modern React + TypeScript project. cd my-react-app && npm installto pull dependencies andnpm run devto start the development server.
Learn the Core Concepts
- Components: Functions that return JSX. Keep them small and focused.
- Props: Component inputs. Use TypeScript interfaces to document them.
- State: Call
useStatefor local state anduseEffectfor side effects such as fetching data. - Composition over inheritance: Build complex UIs by nesting components.
import { useState } from "react";
export function Counter() {
const [count, setCount] = useState(0);
return (
<button onClick={() => setCount((value) => value + 1)}>
You clicked {count} times
</button>
);
}
Project Structure Tips
- Keep UI primitives in a
/componentsfolder and domain-specific logic in/featuresor/modules. - Co-locate CSS (or SCSS) modules with the component they style so refactors stay simple.
- Add ESLint + Prettier early to enforce consistent patterns.
Practice Next Steps
- Fetch remote data with
fetchinsideuseEffect, render loading and error states, and memoize derived data withuseMemo. - Try React Router or Remix to add multiple pages.
- Ship a small component library to cement the basics.
React rewards iteration. Start tiny, keep your components pure, and the rest of the ecosystem—hooks, routers, build tools—will slot neatly into place.