Created
February 26, 2021 10:55
-
-
Save KevinVR/4466e2a176b12c3cc7efea4f04e87bad to your computer and use it in GitHub Desktop.
This file contains 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
import React, {useState} from 'react'; | |
function MyStateComponent = ({ showHeading }) => { | |
// Use the useState hook from react | |
// Let's define the headingText in the state | |
const [headingText, setHeadingText] = useState('Default Heading'); | |
// If the showHeading prop is true, we will show the heading | |
return showHeading ? <h1>{headingText}</h1> : null; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment