Created
February 1, 2021 23:20
-
-
Save caelinsutch/dd3e8635001976691b459af632b601a1 to your computer and use it in GitHub Desktop.
Default Props
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Don't define the default props outside of the function | |
const Component = ({ title, subtitle, text}) => { | |
return <div>..</div> | |
} | |
Component.defaultProps = { | |
title: 'Default Title', | |
subtitle: 'Generic Subtitle', | |
text: '' | |
} | |
// Put default props inside of the destructuring statement | |
const Component = ({ | |
title: 'Default Title', | |
subtitle: 'Generic Subtitle', | |
text: '', | |
}) => { | |
return <div>...</div> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment