Skip to content

Commit

Permalink
Add extra credit solution epicweb-dev#3
Browse files Browse the repository at this point in the history
  • Loading branch information
kzapata19 committed Dec 30, 2022
1 parent 2bcdc43 commit 033ef5f
Showing 1 changed file with 34 additions and 7 deletions.
41 changes: 34 additions & 7 deletions src/exercise/04.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,43 @@
// <div className="message">{message({children: 'Goodbye World'})}</div>
// </div>
// )
function Message({children}) {
return <div className='message'>{children}</div>
}
// function Message({children}) {
// return <div className='message'>{children}</div>
// }

// const element = (
// <div className='container'>
// <Message>Hello World</Message>
// <Message>Goodbye World</Message>
// </div>
// )

function Message({greeting, subject}) {
return (
<div className='message'>{greeting}, {subject}</div>
)
}

const PropTypes = {
string(props, propName, component) {
if(typeof props[propName] !== 'string') {
return new Error(`Entry is ${typeof props[propName]}. Please use a string`)
}
},
}

Message.propTypes = {
greeting: PropTypes.string,
subject: PropTypes.string,
}

const element = (
<div className='container'>
<Message>Hello World</Message>
<Message>Goodbye World</Message>
</div>
)
<Message greeting="Hello" subject="World"/>
<Message greeting="Goodbye" subject="World"/>
</div>
)

// 💯 This is only the first step to making actual React components. The rest is in the extra credit!
ReactDOM.createRoot(document.getElementById('root')).render(element)
</script>
Expand Down

0 comments on commit 033ef5f

Please sign in to comment.