Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    ⚛React

    Components and JSX

    • Why React?
    • JSX rules
    • Props
    • Rendering lists and keys
    • Conditional rendering

    State and events

    • Handling events
    • useState: a component's memory
    • Objects and arrays in state
    • Forms and controlled inputs
    • Lifting state up

    Effects and essential hooks

    • useEffect
    • Fetching data
    • useRef
    • Context: data for the whole tree
    • useReducer

    Professional React

    • Writing your own hooks
    • Performance: memo, useMemo and useCallback
    • Suspense and error boundaries
    • What's new in React 19
    • Thinking in React
    • Project: a complete to-do app
    React

    Components and JSX · Lesson 1 of 21

    Why React?

    UI as a function of data, components, and your first App.

    7 minutes2 games

    In plain JavaScript, when data changes you find elements on the page and update them one by one: "change this text, add that element, remove this class". In big apps that gets very hard and breeds bugs.

    React flips it: you describe what the page looks like for any given data, and React works out what changed and updates the page. That's the declarative style: UI = f(state).

    React
    function Welcome({ name }) {
      return <h2>Welcome, {name}!</h2>
    }
    
    function App() {
      return (
        <div>
          <Welcome name="Laila" />
          <Welcome name="Omar" />
          <p>Built from small, reusable components.</p>
        </div>
      )
    }

    Welcome is a component: a function returning part of the page. Its name must start with a capital letter. We use it like an HTML tag: <Welcome name="Laila" />. Whole pages are built from small components nested inside each other, like LEGO.

    • <App>
      • <Header>
        • <Logo>
        • <SearchBox>
      • <CourseList>
        • <CourseCard> × 6
      • <Footer>

    Any page (SeaCode's included) is a tree of components.

    Important

    React is a library for building the UI only. Routing, server data and SEO aren't part of it, which is why it's used inside frameworks like Next.js (the next track), which SeaCode itself is built with.

    Quick question

    What does it mean that React is "declarative"?

    Interview question

    What is the virtual DOM, and is it what makes React fast?

    Exercise

    Make a Badge component that takes a label and returns a <span> with it. Use it three times in App: HTML, CSS and React.

    The page should show: HTML CSS React

    React
    function Badge({ label }) {
      return null
    }
    
    function App() {
      return (
        <div>
          
        </div>
      )
    }

    Learn more from

    • react.dev: Quick startreact.dev
    • react.dev: Your first componentreact.dev
    • react.dev: Preserving and resetting state (reconciliation)react.dev
    • MDN: Getting started with Reactdeveloper.mozilla.org

    Played 0 of 2 games

    Sign in to save your progress and earn XP.

    NextJSX rules
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.