How to create a simple counter Using ReactJS?
We’ll be creating a simple application where we have 2 buttons one to increment and one to decrement.
Initial Setup: The npx is a CLI tool used to install and manage dependencies in the npm registry. NPX comes pre-bundled with npm 5.2+, else we can install it using the following command:
npm i -g npx // -g flag indicates global installation
Creating React Application:
Step 1: Create a React application using the following command:
npx create-react-app counter
Step 2: After creating your project folder i.e. counter, move to it using the following command:
Project Structure: It will look like the following.
Step to Run Application: Run the application using the following command from the root directory of the project: