13 Tweets 2 reads Mar 15, 2023
If you are learning React in 2023.
Here's the complete guide To build a Counter App in React:
Prerequisites:
• HTML
• CSS
• Basics of JavaScript ES6
• Basics Of React Library
Step 1: Let’s Create a React app in just 5 Clicks.
We have 3 Files:
App.jsx
App.css
Index.jsx
Step 2: Write logic and structure of the application inside App.jsx
• Declare a state count and a function setCount to get updated value of count. This can be done using the useState hook.
• Define three functions onIncrement, onDecrement & onReset.
• onIncrement function will increase the count value by 1.
• onDecrement function will decrease the count value by 1.
• onReset function will reset the count value to 0.
Step 3: Write JSX
• We need a card, inside the card a text and 3 buttons.
• Text: to display the value.
• Buttons: + , - & Reset.
• + is to increment value by 1.
• - is to decrement value by 1.
• Reset is to reset the value to 0.
Step 4: Let’s see how we can use a AI code brushes.
• Select the code you want to add comments.
• Click “Document” under code-brushes.
• Boom💥💥– Automatic comments added to the functions.
Step 5: Now, let’s style our Counter App.
Write CSS on App.css file.
Now here’s some challenges for you:
1. Increment and decrement the count by 10, instead 1.
2. Make two text boxes, each with two buttons; the first box should only increase the number by 5, and the second box should only decrease the value by 5.
Challenges added in code file👇
Here’s the code of counter app:
codedamn.com
Complete the challenges and let us know in the comments 📝
That's a wrap!
if you enjoyed this thread:
1. Follow us @codedamncom for more of these.
2. Retweet the first tweet above to share with your friends.

Loading suggestions...