Skip to content

Commit

Permalink
react node is better
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Mar 19, 2024
1 parent 4462c35 commit 8cd8e05
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions exercises/02.composition/01.problem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ function App() {
style={{ ['--accent-color' as any]: selectedSport?.color ?? 'black' }}
>
{/*
🐨 make Nav accept a ReactElement prop called "avatar"
🐨 make Nav accept a ReactNode prop called "avatar"
instead of a User prop called "user"
*/}
<Nav user={user} />
<div className="spacer" data-size="lg" />
{/*
🐨 make Main accept ReactElement props called "sidebar" and "content"
🐨 make Main accept ReactNode props called "sidebar" and "content"
instead of the props it accepts right now.
*/}
<Main
Expand All @@ -38,7 +38,7 @@ function App() {
)
}

// 🐨 this should accept an avatar prop that's a ReactElement
// 🐨 this should accept an avatar prop that's a ReactNode
function Nav({ user }: { user: User }) {
return (
<nav>
Expand Down Expand Up @@ -81,7 +81,7 @@ function Main({
}

function List({
// 🐨 make this accept an array of ReactElements called "listItems"
// 🐨 make this accept an array of ReactNodes called "listItems"
// and remove the existing props
sportList,
setSelectedSport,
Expand Down
8 changes: 4 additions & 4 deletions exercises/02.composition/01.solution/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function App() {
)
}

function Nav({ avatar }: { avatar: React.ReactElement }) {
function Nav({ avatar }: { avatar: React.ReactNode }) {
return (
<nav>
<ul>
Expand All @@ -63,8 +63,8 @@ function Main({
sidebar,
content,
}: {
sidebar: React.ReactElement
content: React.ReactElement
sidebar: React.ReactNode
content: React.ReactNode
}) {
return (
<main>
Expand All @@ -74,7 +74,7 @@ function Main({
)
}

function List({ listItems }: { listItems: Array<React.ReactElement> }) {
function List({ listItems }: { listItems: Array<React.ReactNode> }) {
return (
<div className="sport-list">
<ul>{listItems}</ul>
Expand Down
4 changes: 2 additions & 2 deletions exercises/02.composition/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function App() {
)
}

function Child({ grandChild }: { grandChild: React.ReactElement }) {
function Child({ grandChild }: { grandChild: React.ReactNode }) {
return (
<div>
<strong>
Expand All @@ -81,7 +81,7 @@ function Child({ grandChild }: { grandChild: React.ReactElement }) {
)
}

function GrandChild({ button }: { button: React.ReactElement }) {
function GrandChild({ button }: { button: React.ReactNode }) {
return (
<div>
<small>I am a grand child and I just pass things off to a button</small>
Expand Down

0 comments on commit 8cd8e05

Please sign in to comment.