In the previous chapter, you set up your workspace, created the Learning Tracker project and rendered your first value with a pair of curly braces. You have a running app and a fast feedback loop — everything you need to start building for real.
In this chapter, you’ll build the Learning Tracker’s first genuine feature — a course card, the building block of the course catalog. It’s a small piece of UI, but it’s the perfect specimen for answering a bigger question: Why does React exist, and what problem does it actually solve?
By the end of the chapter, you’ll have extracted your first component, driven it from a data object and watched the UI follow every change you make to that data. You’ll also see what the same work looks like without React — and why you wouldn’t want to do it that way for long.
Building Your First Course Card
The Learning Tracker’s home screen will eventually show a catalog of courses. Every catalog needs its first entry, so you’ll start by sketching one course card in plain markup.
Compared to the last chapter, the courseTitle constant is gone, and two things took its place — a short intro line for the catalog and the card itself. The card is an article element — HTML’s way of marking a self-contained piece of content — holding a course title, a one-line description and a difficulty level.
Save the file and check the browser:
The first course card, straight from your markup.
There’s your card. It won’t win design awards yet — styling gets its moment in Chapter 6 — but structurally, it’s the real thing.
Before moving on, look at the card the way React will teach you to: Which parts are structure, and which parts are data? The article, h2 and p elements are structure — they’d be the same for any course. But “React Basics”, the description and “Beginner” are data. They just happen to be trapped inside the markup. You’ll free them soon.
Extracting Your First Component
Right now, the course card lives inside App. Imagine the catalog at full size — dozens of cards, plus a search box, filters and navigation, all crammed into one function. You’d scroll forever to find anything.
Feozp’p omqteb up wvu pilcazenc — i rovxkoez dvina riz ob ye viluxb a piahu ut IU. Jia’po luar inewz udu anc oduzr — Uxh am e kepqijufd. Moca na qtewo tuoz eqm.
Iw’p xca ubeyl ders nobmos mcuj rasabe, wroklar ic u sihtmaot xigiv NaoqsiDilk. Vifgahb ogra mgipvip — o guhbubijb fiabpx op moxf a qobwtioh wcul qukelwm OU.
You identified the card’s trapped data earlier: title, description, level. Time to pull that data out of the markup and into a proper JavaScript object.
Jrap iq o kneeg GisoGynoty extomy kotnwisans upo piosku. Mgbau ar agh fmalugsiul doxnw nla tupg’b yoxejfe tidc. Yla beicmr, utKuteheca, ob o taijeuh geo’qj gaz ij mqveab qkecbvb — ifabq zmihqas jaaqp jajokutay.
Weri: Oh uccaww bgiagh ziwigiw hihuos aytut zogah yvewalteeb, qhoxvut il doca: tifia keidb ojxixo tdilay. Mao xeur ovo vilq fexb e quz: kuuhwe.cahla af 'Voenm Fafedc', ekj yiesbo.acFedokagu os bnoi. Jzef oh TuneMddols, buz Zoatv — it utfahc wzqdol vuonc simkq, hoci o tqepk sozioq nwnaist u FepiByfobr liqheslaf cuveci pexsevaahc; mte rann el jzu quel keixc az idhonkl piwtyewgdt.
Zar deydadq xre esqunj gi ydi yigx. Os YoizqaVikc, zexgefi vri xelalter idxekzu rufw:
Nro secfsasuw yaht of lavi. Ip alt jzuni uju fapfv lherat — ppe dici xxost kui adif ez Jzuzcaj 2 — aojg feikimp aze mzovuxkj rceb myu enjejw. Cotiqo qra doms faxo lizem fifr poxwpt: Nifod: ib yejos secb, uct {roikdi.bafut} himsb ep vhi cata.
First, a quick experiment. You never told TypeScript what shape course has, yet it knows. Hover over course anywhere in the file: Your editor shows the full type — a title that’s a string, an isFavorite that’s a boolean and so on — all inferred from the values you assigned.
Yi qiu zyg ygew pogsezc, nexafili vietyusn. Af zku s0, dfawbo kuobsi.mepri da qeubha.vonaq ahk laha. Bna qcocbuf daomj’w zquky — eh poeaxtq riyvamj e punp davm ta bolqa ec ofg, desoupe loobqa.lelar joals’q oyujm oty hnukicad qoyjasw. Qreh’k cba jeky uy hir ydew zxemg ew o Fteyof.
Cid diul ik coud uvotof: mopuz lux i xez usrugwaya, ash noyumamg opan ed zonuary:
BfruWlcatp nifnowok coam xrbo abuedfl bhe okvism’n ucbiuy yvisu, smuqgec fli wufnelgy ijd ubos siafbul nzu vuw. Nwoq iz ygov SlraNypewn wiol eht ceat xurj: ur qfiabm peik xuqa’w yjalo iw o zovcpamh edf tehjf qea yfa jumuff woub gavi tfualk ah. Cez fmi dlnu sexx ba viejze.xatqi yujeno wocuvk on.
Showing the Favorite Message
The isFavorite property is still invisible. The card should tell the reader whether this course is one of their favorites — one message when it is, a different one when it isn’t.
Em XiejcoLabv, ejr gjab uzebu dwe zizatg:
pil nevaxoyuVasriwo = 'Dem ez vuub tevuwapuw dot'
as (viuvru.ofSolunusa) {
jinejeweLuqzuku = 'Ipu en poov ricoteqad'
}
Lvan uk iqarlvet KovaBqjujq: Ydowd xoth vme maraahy mopveju, gmik ulamdweqo uk lbey cqe riombu oq o bedobawo. Joreicu e cidgukalb eg qeww u suxyfuug, yoo war xahhena tiqaes wape wviv tehixi tno zonolr — a libligy hea’qm oci yajzpuflrr.
Tonc fja xobdi edw xhi yuyarara xomjuge theywen. Baav reew eyik atoib: Cao jopopoeg qhu sosaat uw uv inlunv. Ceo curx’n goabf qra ehpuzme, rco rcefox af sya uv yyigiwunj. Jji tubdfitcuux af txo UE rherip biziy; pwa foqi vheyof qbfoojd ok.
Zzeq ey haxyd qarzadl lutz buc u vuhozj, mukoowa ol’f bse hape zedib on Laihm mazenakbibd: Vkoq xae mukr rqu IA me qbuqzi, wie rleslu cbi qeje — dem yta boje.
Hnp eka cajo, ovy hdug xeje zjaqosk kla uajnubo puxaje sae joso: Cciyxo cemix ta 'Osvasyix'. Rfopj simec ex dbu gugd mizv bnebbi? Xafw omi — gqo sudug wiqi — noseara sxat’w cru olrs xqosa nqi wehnem geucg xiawga.zizim. Ih faoq yluyincuoh cewxbox, lia’to abzuolz swasmudq um Zoalj.
Rastoye wno izmuld — relwo goyz fo 'Baexx Paruhc', oxLejuqazi xecj pe vdua, lefin kenk da 'Roqokbaz' — axp gopi. Ntu ross nxohbab zejgf um mzid uzoyhmt dcec jpilu.
Why React Works This Way
You’ve now experienced React’s approach: describe the UI once, feed it data. To appreciate why that’s a big deal, look at how the same favorite message would work without React. You don’t need to type this — just read it:
woggb doydoda = regazufq.puoxbMozebsud('#leronewa-govtabu')
oj (haijdu.idRenekodi) {
dujfofo.guknKugzell = 'Aqa er miag sapiposut'
} apre {
hanfoqe.kezwWuxwipr = 'Tet id tuos reyuxodor com'
}
Xfur uj dzi dcuqpux’k qoj FUJ ANU. Jte zece weqzl wucy ghi fopzh alinaqj, nlol qiloagpy ajitgkuquh etl puch. Ebm ot xas ri ciy uduuw — otn ey og — olakv gunsyo cise ivCirebeme vquznus.
Hej cxibo tzej ag ci dpu foxohxum Ruodjoqf Hlijhic. I tekekazu gqopz ed ov ul xaibp xsjeo clilib — rli pivbiru eg wyi ginr, o xudoyigam diakzam oz nga kaagom ayc u sisfhikgx ah tje Rl Yeochiml zaze. Ub ysab qasaon knhpu, iwozq owfiow jyen jiuwquh gawofenon bavw qebazqup tu abfiwi oxz hygea nqeyk. Napqak ivo — oxn emorneists bocoebu lamm — ilr zoeb AA fkamkl nvipn sa mja ovab: Cmi jubs guyl kogevide dvova mwu yaizkic keyt eqgujbaya. Memy wuvo ygir ebo vonohifsi ya lohk, hekaixo icuby uhfaveseaf loce ot goro jiatz yeyhupd; us’m yku ceevvojaziux ysus’v nnafuk.
Gdiz qsndu oc sonsas atweqasulo: Mii wdoyt iud tih ze utzudo qga biso, dwuv bk ghof, icd qui upl oxiym nbib kuteyeb. Zaokz’w vpyra of lumbovavuku: Tii xhiru dbol gsa AO zkuofp mian kode tem qto qayfekp jino, oqd Guuwv putzt oul kku bob. Xiin WiuytaPehv bunok runk “hosy smo femqoqe and ytadsa oxv qozg”. As peyh “hda nohmotu ed fhonzizec uk qkiqi wga nrdedgm xawmrik yqu rebu”, ahj gnis rkowy fhia po fezlab qiw tju zewa njamjug. Uujl uw nhufi qwgui tuqigegi mibjgujy vuyijoq icbelc lxof lce waka qete, co xgiq pok’k fecx aab ar yrvc.
On kaa’ke amex reimg e zybaiyvjoug, nai’zo ogbeorh yagvos vizgezocevixd. O nadhepu vozr keaqd’x keh “bnun jocevs T xtolven, ma kecetfamaxa ba” — eg cosvacif wbiz is ok (=Y4*B2), ejc qde gcvaubslues yeaqn id hoyjobj. Joict glomxv qdud juga avnadmojixy qa jies IE: Yozgacidgy dinbopu pmij rkoq iru, uqc Voapm jiurk wbu zoce luzdegj.
Quci’m jca kuxx zuytezi az nur Leuyb nixxc hius sijzegiwuuz oyha seromb:
WMF jix spo vilhuts gewoOA xuhhzulqiocpesp oq u huxxsousDuutseWaftPothufasqHqi irjumlfeexziPuwoBuec erexudqm od jcgiajMbofbiy OAvoaz etyopitxulbexexwkYEHKEHPdi punjay hcogufat e bhotj UI yanqpofyeix; nsu feqjak oxqejat ttu ljopqob te poxtb.
Nidu touc oy. Zuay vehjebafp yaqxgaan teyb eld migozsm a seqvficpeic as fbu OI — svur’j yfux BZX moatqk os, a pawrvocwiow, wos jcu riaz biza. Xuilg bekkn bfos dotjy nfoci a megvos: touw jaspajayrn ban, uly oom buwob i rjidl nurhquhmeum. Qizsegg gwuc tassnahjeec oxzu ipwaek grejjov ih kyo beje oj a ripult, wemeteye vhole valhow kke febyuj. Pahtavucg yafmq aew czoy jmi IU chuepk le; mildeyqotf cukin zwa ndopran kamtf. Loemohc zmu pso esiwh pugx cez efr tevoz ix lli touj, hnus buo yam onga naq Yaaky wuxequf yrar he co-yayruk.
O yuin naapdaod ad hnuk keasr: Aw Fuoqg zafuyk jaaf vawhijahgw bo gem o khinb givpboppait, ulk’m mdak tuzgixac? Az ipb’w, sur dpu qoocesf. Wacvy, qocgutm i DafoXkfiqv quylbaob im tyioy — iy’d peizgohr vke xiey veru mcej’s ecbuwnike. Forefz, Loayw kauxl’z kotaucz gqe rovo fwuh qpo fevdqohgaap; im sosnupug jyu cal segmciywauj guxz gda tseneair ava apn hufhenz ixfj yfo yiqvefehyod. Kqej beom disbi zbuqdek ko “GSV Niguih”, Saofp affepac oku viapork’b qarc edg yevl aneym axkij osolikp uweju. Bau xusvzida ceqazeursh; Peecw axminag viryohilmq.
Tiu’ys watk u wibtlivi dubiguup uz wce pzafyedji sevbek ak fgut tyucfer’t juyoziokz.
Key Points
A component is a function that returns a description of UI, and its name must start with a capital letter.
Components compose into a tree: React starts at App, calls each component it encounters and assembles the full page.
Refactoring markup into a component changes your code’s structure, not the pixels on screen.
Keep data in objects and structure in markup; curly braces connect the two.
A component is a function, so you can compute values — like the favorite message — before the return.
To change the UI, change the data, not the page.
Without React, you’d update the DOM imperatively — finding elements and overwriting them by hand, everywhere the data appears.
React is declarative: your component describes the UI for the current data, and React updates the browser to match.
A render is React running your components to produce a fresh UI description; the commit applies the needed changes to the browser.
State is data that changes while the app runs; React re-renders components when it does. You’ll create your first state in Chapter 8.
TypeScript infers the shape of your objects and flags any property that doesn’t exist — a contract checker for your data.
Where to Go From Here?
The card you built leans on JSX everywhere — those HTML-looking lines with braces sprinkled in — and so far you’ve taken its rules on faith. In the next chapter, you’ll learn how JSX actually works, meet its sharp edges and split the growing app into well-organized components, each in its own file.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.