Create a functional component StatefulCounter
that uses the useState
hook to implement a counter.
- Fork the repository containing this exercise.
- Clone your forked repository to your local machine:
git clone <your-forked-repo-url>
- Navigate to the project directory:
cd path/to/repo
- Create a new React application:
npx create-react-app .
- In the
src
folder, create a fileStatefulCounter.js
. - Define
StatefulCounter
as a functional component. - Use the
useState
hook to create acount
state variable and asetCount
function. - Render a button that, when clicked, increments the
count
by 1. - Display the current
count
value on the screen. - Render
StatefulCounter
inApp.js
.
- Commit your changes:
git add . git commit -m "Add StatefulCounter component"
- Push to your fork:
git push
- Create a pull request from your fork to the original repository.