From the course: Learning Full-Stack JavaScript Development: MongoDB, Node, and React

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Function components and props

Function components and props

- [Narrator] React is all about components. Structuring an app as a tree of components is valuable for many reasons. It makes the code more readable and easier to deal with. But it also has value beyond that in terms of design, testability, responsibility, reusability, and even data management. There are no simple rules as to when to introduce a new component. You'll get better at that as you write more components. So far we have the one App component. And theoretically we can write the entire app in a single component. But that would be a terrible thing to do. Let's introduce a header component. Let me remove this title for simplicity. And in here, every page is going to have a header div. The main page header will be Naming Contests. We're going to list the Naming Contests here. On a simple Naming Contest page, the header will show the title of that Contest. So making this header section a component allows us to reuse…

Contents