Skip to main content
← Back to Blog
2026-02-21 · 7 min readWeb DevelopmentUpdated Oct 29, 2026

Getting Started with React: Deconstructing JSX and Component Architecture

A first look at React for developers who know JavaScript. You pick a starting point (a framework or Vite), see what JSX turns into, write function components, pass data with props, and build a reusable dashboard card. The three JSX rules from react.dev come with working fixes, and the card component was built in a Vite project with React 19.

Avnish Yadav
Avnish Yadav
Developer & Automation Builder
8 views
Getting Started with React: Deconstructing JSX and Component Architecture

This guide gets you from plain JavaScript to your first reusable React components. It is for developers who know the DOM and want to understand what React does differently. You will choose how to start a project, see what JSX turns into, and build a dashboard card that takes its data through props.

This is part 18 of the Frontend & JavaScript Fundamentals series. It follows why TypeScript matters. The examples here use plain JavaScript so you can focus on JSX; types come later.

Key takeaways

  • react.dev recommends starting a new app with a framework such as Next.js or React Router, or with a build tool such as Vite. Create React App is deprecated.
  • JSX compiles to plain JavaScript function calls that return objects, so you can store it in variables and return it from functions.
  • A component is a function that starts with a capital letter and returns JSX. Props are its read-only arguments.

From imperative to declarative

With plain JavaScript or jQuery, you work imperatively. You tell the browser each step: find this element, add this class, change this text.

React works declaratively. You describe what the UI should look like for the current data, and React updates the DOM to match. You stop writing "change the text" and start writing "the text is this value".

Start a React project

The react.dev guide recommends a framework for new apps. If you just want to learn, or you need your own setup, it points to a build tool instead.

Option Create it with What you get When to use
Next.js npx create-next-app@latest Routing, server rendering, data fetching Full apps and sites
React Router (framework mode) npx create-react-router@latest Routing and data loading, paired with Vite Apps that want routing first
Expo npx create-expo-app@latest Android, iOS and web from one codebase Native mobile apps
Vite npm create vite@latest my-app -- --template react A fast dev server and build, nothing else Learning React, or building your own stack

For the examples in this post, the Vite react template is enough. react.dev's own example uses react-ts, the TypeScript version; with it, you add types to each component's props. Don't start new projects with Create React App: the React team deprecated it for new apps in February 2025 and now recommends the options above.

What JSX is

JSX is a syntax extension that lets you write HTML-like markup inside JavaScript. react.dev puts it this way: JSX looks like HTML, but under the hood it is transformed into plain JavaScript objects. Browsers can't read JSX, so your build tool compiles it first.

Here is what you write:

const element = (
  <h1 className="greeting">
    Hello, Avnish
  </h1>
);

With the classic transform, that becomes a createElement call:

const element = React.createElement(
  'h1',
  {className: 'greeting'},
  'Hello, Avnish'
);

Current toolchains use the newer automatic transform, added in React 17. It imports a jsx() function from react/jsx-runtime instead, which is why you no longer need import React at the top of every file. The result is the same kind of object either way. The createElement reference calls it a description of what to render, not a DOM node.

That is the key point. JSX is an expression that produces an object. You can store it in a variable, pass it to a function or return it, like any other value.

Components: functions that return JSX

A React component is a JavaScript function that returns JSX. react.dev adds one rule: its name must start with a capital letter. That is how React tells <section> (an HTML tag) from <Profile /> (your component).

Here is a component that shows the status of a background job:

function AgentStatus() {
  const isActive = true;

  return (
    <div className="status-card">
      <h2>Data Scraper Agent</h2>
      <span>Status: {isActive ? 'Running' : 'Paused'}</span>
    </div>
  );
}

The curly braces {} switch back to JavaScript inside JSX. react.dev says any JavaScript expression works there, including function calls. You can use braces in two places: as text inside a tag, and as an attribute value right after the = sign.

Build a reusable card with props

Now build a SystemCard for a dashboard. It takes its data as inputs, so you can reuse it for every service.

1. Define the props

Components receive data through props. react.dev compares them to function arguments: in fact, props are the only argument, a single object that you usually destructure. Data flows one way, from parent to child.

const SystemCard = ({ title, uptime, serverLocation }) => {
  return (
    <div className="border p-4 rounded-lg shadow-sm">
      <h3 className="text-xl font-bold mb-2">{title}</h3>
      <div className="text-gray-600">
        <p>Server: {serverLocation}</p>
        <p>Uptime: {uptime}%</p>
      </div>
    </div>
  );
};

2. Use it from a parent

The parent renders the card twice with different data:

const Dashboard = () => {
  return (
    <section className="grid grid-cols-3 gap-4">
      <SystemCard
        title="Auth Service"
        uptime={99.9}
        serverLocation="US-East"
      />
      <SystemCard
        title="Payment Gateway"
        uptime={98.5}
        serverLocation="EU-Central"
      />
    </section>
  );
};

You wrote the card's markup once. If you change its styling later, you change one component and every card updates. (The class names are Tailwind CSS utilities. Any CSS works.)

Props are read-only. react.dev says not to change them. When a component needs to respond to user input, it uses state, which the next part covers.

Define components at the top level

Never declare one component inside another. react.dev warns that this is very slow and causes bugs. Keep SystemCard and Dashboard side by side in the module, and pass data down with props.

The three rules of JSX

react.dev lists three rules. Each one follows from JSX being JavaScript.

1. Return a single root element

// Avoid: two sibling tags with no parent
return (
  <h1>Title</h1>
  <p>Description</p>
);

This is a syntax error. Each tag becomes an object, and react.dev explains that a function can't return two objects without wrapping them in an array. Wrap them in a Fragment, which adds no extra element to the page, or in a <div>:

// Prefer: a Fragment groups the tags without an extra element
return (
  <>
    <h1>Title</h1>
    <p>Description</p>
  </>
);

2. Close every tag

HTML lets you leave <input> or <br> open. JSX does not. Self-closing tags need a slash, for example <img src="/logo.png" alt="Logo" />.

3. camelCase most attributes

JSX attributes become keys of JavaScript objects, so React uses camelCase names that match the DOM properties.

  • class becomes className, because class is a reserved word in JavaScript.
  • for becomes htmlFor, for the same reason.
  • onclick becomes onClick, and stroke-width becomes strokeWidth.

aria-* and data-* attributes keep their dashes. react.dev also links an HTML-to-JSX converter if you are porting existing markup.

Corrected in this version

The earlier version said Babel turns JSX into React.createElement calls in every project. Modern setups use the automatic JSX runtime. It also explained the single-root rule with a comma expression; the real reason is the one react.dev gives above.

Think in components

React starts with a change in how you see a page. Instead of one document, you see a tree of components: headers, sidebars, cards and buttons. JSX is how you describe that tree, and because it is plain JavaScript underneath, you can build it with everything the language gives you.

Next in the series, state and props in class and function components makes these components interactive.

Frequently asked questions

Do I need to import React to use JSX?

Not with the automatic JSX runtime, which React 17 and later support and current toolchains use. The compiler adds the import from react/jsx-runtime for you. You still import named exports such as useState when you use them.

Is Create React App still a good way to start?

No. The React team deprecated it for new apps in February 2025. react.dev recommends a framework such as Next.js, React Router or Expo, or a build tool such as Vite, Parcel or Rsbuild if you want your own setup.

Can I write React without JSX?

Yes. createElement creates the same elements, and react.dev says both styles are fine. JSX is popular mainly because nested markup is easier to read, and you can see which closing tag matches which opening tag.

What is the difference between props and state?

Props are inputs a parent passes to a component, and the component must not change them. State is data a component owns and updates over time, for example when a user clicks a button. When a value needs to change in response to input, it belongs in state.

Why must component names start with a capital letter?

React uses the case to tell components from HTML tags. A lowercase <profile /> is treated as an unknown HTML element, while <Profile /> calls your function.

Sources

Verified against the sources below on October 29, 2026. Products and docs change often: check the linked sources if something looks different.

  1. react.dev: Creating a React App
  2. react.dev: Build a React app from Scratch
  3. react.dev blog: Sunsetting Create React App
  4. react.dev: Writing Markup with JSX
  5. react.dev: JavaScript in JSX with Curly Braces
  6. react.dev: Your First Component
  7. react.dev: Passing Props to a Component
  8. react.dev reference: createElement
  9. React blog: Introducing the New JSX Transform
All 30 parts in this series
  1. Part 01Overcoming the Daunting Start: A Strategic Roadmap for New Frontend Developers
  2. Part 02Beyond the Tags: Mastering HTML Architecture for Product-Based Roles
  3. Part 03From Selectors to BEM: CSS Concepts You Must Know for Professional Projects
  4. Part 04Mastering the Primitives: A Builder's Guide to JavaScript Data Types and Functions
  5. Part 05Demystifying Scope and Closure: Key Concepts for Writing Robust JavaScript
  6. Part 06Beyond Frameworks: Practical DOM Manipulation Techniques for High-Performance UIs
  7. Part 07From Prototypes to ES6 Classes: Understanding JavaScript's Object-Oriented Nature
  8. Part 08Architecting Scalable JavaScript: OOP Principles & Design Patterns
  9. Part 09Mastering the Metal: Essential Web APIs & Browser Internals for Frontend Engineers
  10. Part 10Understanding the JavaScript Runtime: Event Loop, Call Stack, and Task Queue Explained
  11. Part 11Mastering Asynchronous Operations with JavaScript Promises: A Builder's Guide
  12. Part 12Modern Async Patterns: Making Asynchronous Code Readable with Async/Await and Generators
  13. Part 13Inside the V8 Engine: A Deep Dive into JavaScript Execution
  14. Part 14Demystifying CORS, HTTP, and Security: A Builder’s Guide
  15. Part 15REST vs. GraphQL: A Frontend Engineer’s Reality Check
  16. Part 16Secure Frontend Auth: The Definitive Guide to JWTs, Cookies, and Storage Strategies
  17. Part 17Why TypeScript Matters: Adding Type Safety to Your JavaScript Projects
  18. Part 18Getting Started with React: Deconstructing JSX and Component Architecture
  19. Part 19React Architecture: Mastering State and Props in Class vs. Functional Components
  20. Part 20Mastering React Hooks: From useState to Building a Production-Ready Custom Hook
  21. Part 21React State Management: Context API vs. Redux & Building a Theme Switcher
  22. Part 22React Architecture: Advanced Navigation and Data Flow Patterns
  23. Part 23Automated Testing in React: Unit Testing with Jest and React Testing Library
  24. Part 24Mastering Chrome DevTools: Debugging Techniques That Save Hours of Development Time
  25. Part 25Automating Code Quality: The Modern Stack with ESLint, Prettier, and Husky
  26. Part 26Demystifying the Build Pipeline: A Deep Dive into Webpack and Babel Configuration
  27. Part 27Improving Performance with Server-Side Rendering: Concepts and Implementation
  28. Part 28From Development to Production: A Builder's Guide to Frontend Deployment Strategies
  29. Part 29Introduction to Micro Frontends: Building Scalable Architectures
  30. Part 30The Frontend Architecture: From Junior Developer to Tech Lead
Share
Discussion

Comments

Loading comments...

Add a comment

Comments are reviewed before they appear.