React is a JavaScript library for building user interfaces out of components: small, reusable functions that return what part of the page should look like. Components receive data through props, keep their own changing data in state, and use hooks such as useState and useEffect to manage state and side effects. When state changes, React re-renders the affected components and updates the page efficiently.

Why is React so widely used?

Building interactive interfaces by manually changing the page (finding elements, updating text, adding and removing nodes) becomes error-prone as apps grow. React's idea is declarative: you describe what the interface should look like for the current data, and React works out the minimal changes. Components make code reusable and testable, a large ecosystem covers routing, forms and data fetching, and React Native extends the same ideas to mobile apps. Many Indian startups and product companies use React, which is why it appears in so many job descriptions.

What should you know before starting?

PrerequisiteWhy React needs it
HTML and CSSComponents output HTML-like markup that must be styled
JavaScript functions and objectsComponents are functions; props are objects
map, filterRendering lists and transforming data
Destructuring and spreadReading props; updating state immutably
Modules (import/export)Splitting components across files
Promises and async/awaitFetching data from APIs

What are components and JSX?

A component is a function that returns JSX, a syntax that looks like HTML inside JavaScript: function Welcome() { return <h1>Welcome to class</h1>; }. JSX compiles to JavaScript calls; you use className instead of class, and curly braces to insert values: <p>{learner.name}</p>. Components compose: a CourseCard can be used many times inside a CourseList, which sits inside a Dashboard.

What are props?

Props are inputs to a component, passed like HTML attributes: <CourseCard title="Machine Learning" weeks={6} />. Inside, the component reads them: function CourseCard({ title, weeks }) { ... }. Props flow down from parent to child and are read-only: a component shouldn't change its own props. To let a child affect the parent, pass a function as a prop (for example onSelect) that the child calls.

What is state, and how does useState work?

State is data that changes over time and affects what's shown: a counter, form input, a toggled menu, fetched data. const [count, setCount] = useState(0); gives you the current value and a setter. Calling setCount(count + 1) schedules a re-render with the new value. Never change state directly (count++ or pushing into a state array); always create a new value, for example setItems([...items, newItem]), so React notices the change. When the new value depends on the old one, use the updater form: setCount(c => c + 1).

What does useEffect do?

useEffect runs code after rendering, for "side effects" such as fetching data, setting up subscriptions or timers. Its dependency array controls when it re-runs: [] runs once after the first render, [courseId] re-runs when courseId changes, and returning a function cleans up (clearing timers, closing connections). Many beginner bugs come from missing dependencies or effects that update state they depend on, causing infinite loops. For data fetching in larger apps, libraries such as React Query or framework features often replace hand-written effects.

How do you render lists and handle forms?

  • Lists: courses.map(c => <CourseCard key={c.id} {...c} />). The key must be a stable unique ID (not the array index when items can reorder) so React can track items correctly.
  • Conditional rendering: {isLoading ? <Spinner /> : <CourseList />} or {error && <p>{error}</p>}.
  • Forms: controlled inputs store their value in state (value={email} and onChange={e => setEmail(e.target.value)}), making validation and submission straightforward.

Which other hooks and concepts come next?

ConceptUse
useContextShare data (theme, logged-in user) without passing props through every level
useReducerManage complex state with explicit actions
useMemo / useCallbackAvoid expensive recalculation or unnecessary re-renders, when measured to matter
useRefAccess DOM elements or keep values without re-rendering
Custom hooksReuse stateful logic, such as useFetch
RoutingMultiple pages with React Router or a framework

How long does it take to learn React?

A typical beginner path in weeks (after JavaScript basics)
JSX, components, props1
State, events, lists, forms2
Effects, fetching data, routing3
Project with a backend API4

A planning guide for about an hour or more of practice a day, not a guarantee; cumulative weeks shown.

What mistakes do beginners make?

  • Mutating state directly instead of creating new arrays and objects.
  • Using array indexes as keys for lists that change.
  • Putting everything in one giant component.
  • Fetching data in an effect without handling loading and error states.
  • Storing values in state that can be computed from other state.
  • Reaching for global state libraries before they're needed.

How does React connect to the backend and AI features?

A React frontend talks to a backend API (see building a REST API with Node.js) for data and authentication, and can receive real-time updates over WebSockets. AI features, such as a chat assistant or smart search, are usually called through your own backend so API keys stay secret, with responses streamed to the UI for a fast feel.

How should a React project be organised?

Start simple: a components folder for reusable pieces, a pages (or routes) folder for screens, and a small api module that wraps calls to your backend so components don't repeat fetch logic. Keep components small and named for what they show (CourseCard, ProgressBar). Lift state up to the nearest common parent when two components need it, and only introduce global state when many distant components share it. Use a modern build tool such as Vite to create the project, and add ESLint and Prettier early so the code stays consistent as it grows.

How do you style React components?

Options include plain CSS files or CSS modules, utility-first frameworks such as Tailwind CSS (common in new projects and taught in Program Zero), component libraries that provide ready-made accessible buttons, dialogs and forms, and CSS-in-JS libraries. Whatever you choose, keep layouts responsive so they work on phones, which is how most Indian users browse, and check keyboard navigation and colour contrast for accessibility.

How do you test React components?

Testing Library encourages tests that behave like a user: render a component, find elements by their visible text or role, simulate clicks and typing, and assert on what appears. Test the important behaviours (a form shows an error for an invalid email, a list shows a loading state then the courses) rather than implementation details. Tests make refactoring safe and are a strong signal of professional habits in a portfolio project, which reviewers notice quickly.

Start with one or two tests for your most important component, then add a test whenever you fix a bug, so the same bug can't quietly return later.

How should you practise?

Build a to-do app, then a course-catalogue app that fetches data from an API with search and filters, then a full-stack app with login. Program Zero's full-stack development course covers React and hooks, Tailwind, Node.js APIs, authentication, WebSockets and React Native basics, with real projects. Unsure where to start? Read JavaScript vs Python: which to learn first.