Lesson 12/100

Tutorials React.js Tutorial

Props Destructuring — Complete Guide

Props Destructuring — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of React.js Tutorial on Toolliyo Academy.

On this page

React.js Tutorial · Lesson 12 of 100

JSX

BeginnerIntermediateAdvancedProfessional

Beginner · 1 — Foundations · ~12 min read · Module 2: JavaScript & React Fundamentals

Introduction

This lesson is part of the beginner section. We explain JSX slowly, with examples you can copy and run. If something is unclear, read it twice — that is how everyone learns. JSX lets you write HTML-like tags inside JavaScript. It looks strange at first, but it is how almost every React app is written. Your editor shows it in one file — logic and layout together — which is easier to follow than jumping between files. You could build React without JSX, but you would write long, hard-to-read code. JSX is the friendly syntax beginners see in every tutorial and job codebase.

JSX appears in almost every file you will write. Once it clicks, later lessons (hooks, routing, APIs) become much easier.

When will you use this?

You use this in every component you write from your first app to your tenth year on the job.

  • Product pages, login forms, and todo lists all use components, props, and state.
  • When a user types in a search box, React state holds the text and filters a list.

Real-world: Practo appointment booking UI

Practo booking screen mixes HTML structure with JavaScript expressions — doctor name, slot time, and fee come from variables, not hard-coded text.

Production-style code

function AppointmentSlot({ doctor, slot, fee, onBook }) {
  const isEvening = slot.hour >= 17;
  return (
    <div className="slot-card">
      <h3>{doctor.name}</h3>
      <p>{doctor.specialty}</p>
      <time dateTime={slot.iso}>{slot.label}</time>
      <p className="fee">Consultation: ₹{fee}</p>
      {isEvening && <span className="badge">Evening slot</span>}
      <button type="button" onClick={() => onBook(slot.id)}>Book</button>
    </div>
  );
}

What happens in production: Designers hand off Figma frames; developers translate them to JSX with dynamic data — one language for structure and logic.

Lesson example (start here)

Copy this smaller example first. Once it works, compare it with the real-world code above.

function Welcome() {
  const name = 'Ravi';
  return (
    <div className="card">
      <h1>Hello, {name}!</h1>
    </div>
  );
}

Line-by-line walkthrough

CodeWhat it means
function Welcome() {Defines a function — often a component or event handler.
const name = 'Ravi';Part of the JSX example — read it together with the lines before and after.
return (Sends UI or a value back to whoever called this function.
<div className="card">JSX tag — a UI element or custom component on the page.
<h1>Hello, {name}!</h1>JSX tag — a UI element or custom component on the page.
</div>Part of the JSX example — read it together with the lines before and after.
);Closes a block started by { or ( above.
}Closes a block started by { or ( above.

How it works (big picture)

  • Use className instead of class.
  • Put JavaScript expressions inside curly braces { }.
  • The return must have one parent element (or use a Fragment <>).

Do this on your computer

  1. Add a variable and show it inside { } in JSX.
  2. Try className="title" on a div.
  3. Wrap multiple siblings in <> ... .
  4. Read the real-world section and name which part of the app uses this topic.
  5. Run the example locally and confirm the same behavior in the browser.
  6. Change one value in the example (text, initial state, or URL) and predict what will happen before you save.

Experiments — try changing this

  • Change text or labels in the example and save — watch the browser update.
  • Break the code on purpose (remove a bracket), read the error message, then fix it.

Remember

JSX = HTML-like syntax in JavaScript. Use { } for dynamic values and className for CSS classes.

Common questions

Can I use JavaScript without JSX?

Yes, but JSX is standard in React apps.

How long should I spend on JSX?

Until you can explain it in your own words and run the example without looking at the answer. Beginners often need 30–60 minutes per new hook or routing topic; setup lessons may take one afternoon.

What if I get stuck on JSX?

Re-read the line-by-line walkthrough, check the browser console for red errors, and compare your code character-by-character with the example. Search the exact error text — someone else had it too.

Where is JSX used in real jobs?

See the real-world section above — the same pattern appears in LMS, banking, e-commerce, and SaaS products. Interviewers ask you to explain it using one concrete example from your project or this lesson.

Interview prep for this lesson

Practice these questions aloud after reading—each links to a full structured answer.

Mid PDF Detailed
What are props in React?
Short answer: Props (short for &quot;properties&quot;) are read-only data passed from a parent component to a child. ✅ Example code function Greeting(props) { return &lt;h1&gt;Hello, {props.name}!&lt;/h1&gt;; } &lt;Greet…
Junior PDF Detailed
What is the difference between state and props?
Short answer: Feature Props State Mutable? ❌ No (read-only) ✅ Yes Who sets it? Parent component Component itself Used for Passing data Handling internal data Real-world example (ShopNest) ProductCard receives price via p…
Mid PDF Detailed
React Developer Tools:?
Short answer: Use the Profiler tab to measure the render times and identify slow components. Check for unnecessary re-renders and optimize with React.memo or shouldComponentUpdate. Real-world example (ShopNest) ShopNest’…
Mid PDF Detailed
Mock axios:?
Short answer: import axios from 'axios'; jest.mock('axios'); axios.get.mockResolvedValue({ data: 'mock data' }); Example code import axios from 'axios'; jest.mock('axios'); axios.get.mockResolvedValue({ data: 'mock data'…
Mid PDF Detailed
Choose a Testing Library: Use libraries like Jest (test runner) and React Testing?
Short answer: Library (for testing React components). Real-world example (ShopNest) ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state. Say this in the…
Questions on this lesson 0

Sign in to ask a question or upvote helpful answers.

No questions yet — be the first to ask!

React.js Tutorial
Course syllabus

React.js Tutorial

Module 1: React Basics & Setup
Module 2: Props, Events & Lists
Module 3: Forms & Hooks
Module 4: Routing & Data
Module 5: State & Authentication
Module 6: Architecture & React 19
Module 7: Performance
Module 8: Full-Stack & Real-Time
Module 9: Testing & Deployment
Module 10: ShopCart Projects
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details