๐Ÿ“Š We use cookies & analytics to improve your experience. Learn more
Latest

React & Modern Front-End Development Module 1 ยท Lesson 2 of 15

0% Exit to course

Module 1 ยท Components and JSX Lesson 2 of 15

Props, children and composition

Learning objective

Props are the arguments of a component; children is a special prop holding whatever you put between the tags. Composition โ€” a component that accepts other components โ€” is what keeps a codebase readable.

Worked example

One <Panel title="Fees"> containing different content each time beats three near-identical Panel components. The prop carries the difference; the component carries the shape.

Your practice task

Turn your four components into reusable ones: one Card used in three places with different props, and one Layout that takes children.

Do this before moving on. Reading a solution teaches the shape of it; typing it teaches you.

Key takeaway

Props are the arguments of a component; children is a special prop holding whatever you put between the tags. Composition โ€” a component that accepts other components โ€” is what keeps a codebase readable.

Create free account or sign in

Almost there

15 lessons left of 15

Finish every lesson to unlock the certificate. Each one ends in a practice task โ€” do them and the final project brief writes itself.

Next recommended course Full-Stack Web Development Bootcamp