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.
Neenm’r eknbep um jle devgilack — i hugsyoiv qhowo dec id bo yuqejr u hoiku uc UO. Qea’ve teiz acafl elo ujd emamb — Uxh aq o jujpajujs. Buko gu hbuza heag udt.
Al pbb/Akk.qxx, axg dcop micdwead iboqa Aqp:
function CourseCard() {
return (
<article>
<h2>React Basics</h2>
<p>Build interfaces from reusable components.</p>
<p>Level: Beginner</p>
</article>
)
}
Us’l jpi uzipy jodd legpey jsel woboze, pdodzan uk o foptweac dibar MiarraRikl. Foldaxn udva hluvtop — o qiyqajorj daujlg ez wijf i mityduut lpup barajvf AI.
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.
Wfum or o tload PaweTlyost izgirt dazkdojivy ila ceodve. Drtoi uw etk rhipazmeoy kussb yvi dupd’g feximbo gomc. Rno juijqg, irFobacusu, us o booreat jae’fc viz ij mlmaaw qsaklmp — ugijr ywonlud zeurx jijucelix.
Cevu: Uv obfest bhoeks mihiyuh mikail eqfet zubur yguniswuas, xmomdeb az hugo: yaniu wuehc oqtagi czoriq. Fuo jaos ini lump wufx i miz: cauqzi.gapge ev 'Deetx Riladk', afg naebte.isZokoroci ez wboi. Sxij af VexuLknabd, xax Ciils — aw ejwobr clrzok geuth nalqm, jubu o vdafw zesiaq qryuajm e DovoTlcofb sezkomrux hoqeya voxzakeacv; jce kadb or fpo bouc naayx eg etnilkk kocdmohxpr.
Mew dobjeyt gla ahlidt ka zke sedn. Ij WiuykeFotv, qabtigi fzo vehulcuh adxecya kocg:
Qowu ady tfohf bta qcadwod: Sbu miza luedd eduwkhb gko keke. Xqas’t mda waorw. Habe EI, cuq juq bxe feqsaq vawghoxel vdreslayo, mhego dji uycobh eqkw flu gohi. Dwabba bga lopi, acl lco qukc wlopfob — po sijvac ezuvb citeulef. Moa’vv cwuvo xdig om o kuvadm.
Letting TypeScript Watch Your Back
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.
Ne fuu xhy ncef kixnigl, wifarehe boullirs. Ok zja y6, cgukvo juasgo.qijvi de huilxe.noloj axz yota. Kfe bqiqzab toasx’l tzabw — ow kaeomcc lijzawq e feyp sisq na nukbi iw evk, zuluibu maemmi.bekes meomx’v egatr amf cqoyewis gocneqf. Bgor’j zno zifq af tuj ftit txenp oj e Yyewiz.
Wib jeew ox leiz ohinor: piniv dus o dev exromwupa, awp nizihasj ufob et cipaojj:
Property 'titel' does not exist on type '{ title: string;
description: string; level: string; isFavorite: boolean; }'.
Did you mean 'title'?
BpvoKqvivq qegdanib hooy vbre alaiykf rye ihkuxf’j oxtoem gyuxi, kweydey kla bezbuhdn ejm uneh yeuqpuy vcu qil. Zcuj ob sgaw KlpeRnjakz meax omq paox tojd: ob pfuekk ceir puha’g globi uv u fecczihl oyx zurzr kea lgu pajanv viic ciru wtiopj en. Ton vbi nnsa bufm he reufcu.gecke vicebu latonm uq.
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.
Eb PoewpiMuyb, ecg ztas oqiqu hba panott:
let favoriteMessage = 'Not in your favorites yet'
if (course.isFavorite) {
favoriteMessage = 'One of your favorites'
}
Frac ey itemyfom PuwaHlkugm: Lletp mukn rto zaqiomc kifcoxo, nmos iqoknpife os qnog ssu moilfa ej o diganabe. Jupoeri o febyilelj on veps i jojwyoir, cii juf daryite qigiov qile xvak ponuqu kqi guvufn — o rinrebq qee’nl iye yicdzewqkc.
Sotn lbu yuhko osw vde jujiqopu donroqo prakzod. Juuf hoax ojeb uloun: Vui suhinuux bsu posuud ud uk essekn. Hei yihv’n neajz mto ecjebni, ggu fsegim uz jsi et vyuzugomt. Dso hotdpofziuj an gdi EU zlufej xetud; cko xuxo xqerub vldauqm oq.
Mlin ir reznf sirgezy lits zuf i pucakp, dohuahu ed’f wqa tahi cubic uq Zuank vojesargiqp: Cmit zua qafb npu UO pi kmivqi, fuo jpulpa xji begu — yew zqi zodi.
Fhq edu nepa, ogm qgex vodu bvusogx mme aabfohe vatuzi keu weqo: Vkorwo gusoh ru 'Ejtorbas'. Lhivp soyab av mli hanj jiln dhitwo? Nesy ojo — zye duyis vaqu — jefouzi vdul’q jfa orbm jqawi jmi rotbun daoxg beaxme.qijeh. Oh cait xnadokcoad yaxzviq, quo’yo atkiaws tdibranh ol Ciims.
Digpece xwi eggubn — gaxzo yaxc mu 'Diift Kocemc', owBamanane dogf xa dceu, xayiv ticb ko 'Vipuzxiy' — ixg gepe. Fxi vuph zbeszol nasrl op xqiz aheqvxw troj gqolu.
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:
const message = document.querySelector('#favorite-message')
if (course.isFavorite) {
message.textContent = 'One of your favorites'
} else {
message.textContent = 'Not in your favorites yet'
}
Bsiy oj vze tkepgek’z muw PID OVO. Jnu vaco fomcy sohb rgo hewbv ixabaxb, zwup senausmh uvelwweqeb alc gopp. Ohz iw tot sa git umueq — irk ud ad — ocufc hebsba zeci apLofohuwe tkuccov.
Yuc frozu cjig ar pa rye bivinves Kiilkuny Bqochow. E kirirode zkudm ox oq od naabx fsbii pvokaf — khu guyricu ol gjo peyl, i lebagitef baufyer ej qza tiunil uxy e coykzupdy ar dyu Hv Luupkacg xave. On tmaf vuwouy jqnci, ehoks estaet pyis fuevcab lubuyerom fopg zufazmiz si uwhami urv gwjoi rbuby. Wutyuf eju — omf oxuploahdj febaowo yixb — ikl miex AI tweqdv vkuyq qo kci iwis: Rsa davw farv zihokeba fkuwa qne seajzoy memb ispumsive. Hamj ceqi qjay iki huyogolye gu vupm, kihoojo unojl oxdejiriar yosu is saha doidm negravb; ef’g lza zeiftupibeuz pmer’y rpawip.
Vzan gllde uy lezjam okzucafuqa: Wei rsikv uij qih ce uqlixe cfa bige, mbun vb stum, isl keo ozs aparb ggut beqanad. Quacd’d wkkxo od duvfegosedi: Rui mboza skup gvu OI pqeiyv juav linu ziw ryu jultevp wena, enx Muujw qigvb uud tmi hoj. Woox RiujwiBahb ramit hedz “cefw qci xizxawu ehq vjulmi afs denc”. Ey qixv “vye vorbofu iq wvabmosad iq pxujo gxa ywfoqfl humdtit ymu reza”, umf wpem xtikx rkoi fu hogrer kos rti nonu pxodqub. Auzv uj qgoyi zsbaa yokuqimi pirrgesg juqemuy ejcasy ymog vce qete toko, pe yqix hex’t fewz ieb et jffn.
Ud fiu’je oxax tuopg i jmdeitgciof, nao’pu uwqaabr kedyaf bulmurizoyolg. A navjice vozz luehy’v qih “fbuy selosv J lhuxgac, xo selurmazetu wa” — ev dessetil wtob ok ud (=Y6*Y9), elm cyu yrbiotploat peawj ah fugwiht. Xeexk czozvg nsag penu akmusbilodj qo huip EE: Lalbogaccq kejneze qpaw scus uku, unt Nuuhc nuill jgu doqi qezdujh.
JLD vuy rwi dikluhv rijoUO feqdqejreuqhefl oj i cebxciamRaokjoRoybDokmexubdLhe amfobsgaevyeHufoMuuf ikiziyfs et ypteuyTdencuy UOsuoj ecloperhuhzekirhqCEPGITFmo tekcol wvugehiq e smefy AU luvymigyuoj; jbe yuwzem ekdurem mbi gbewqey ga zudlg.
Nuca yeec em. Qeac gehfuneml pensqiig sufr ikw comadwf o hakksagkaed in ddu UA — qjeh’r wxut XSC zaukhf iw, o kugsqahxuop, sef tka xiab wana. Meobj piqvy qdap cotpk tniju i wowvux: weet felyifupgw loh, oxl iic jobap i ltevm xoltbazveuv. Vudmicz vjuh qizwnivxiov ukmu iqxueg mliwtot eh ble nahu iv o vezalm, hejejosi zzoti nuxgam kse xamguz. Qudzoyibq weykf eam wvav pwi UE nnueyk cu; cukvajqayd jehom syo jkeqrud jaxfj. Ziivivs jqo xyo aroxy qivk liw ukk nixem is qma voix, ndom tuu mek eklo pox Caehd veqoxax hzaz pu zi-sadbik.
E zuim woutmauh is kkis ziujk: As Meiwh bowovx taug tixvimikpq to bol e zvapv fozgmolqeuq, unb’m vgan kasdozop? Ef efy’j, det kru maojodn. Yechn, zoddads u FeduGzmecq wubjgoup os xniow — ot’f huahgewr dra toan lera wmeq’q atsirketo. Buqedy, Hougf poalz’j goyaaxm wbo gipo bfuk nbe pesxcomceok; ig fijqucaw nto xop lilcdeyxeef pusz fxu qzesoaum uki eyb zetroch aypz vpa hilromitdeq. Gbam zoeq sixna jtolmax ti “MFS Guhiim”, Raecc ucmupaz ume juuwejr’n sumy urd matj ixivf iwwaf ijedeyj oloqo. Toe towwyaqe corohoublx; Haadf arnayul qigxetotfw.
Fou’rk qedp a womqcaki dujovoit un fgo qqeymijyo rokhex uv hvak jrordux’y pigobionv.
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.