{"id":18759980,"url":"https://github.com/camilopinzon/state-management","last_synced_at":"2026-05-07T09:31:58.497Z","repository":{"id":253052557,"uuid":"842304808","full_name":"CamiloPinzon/State-Management","owner":"CamiloPinzon","description":"Simple counter application where the count value can be incremented, decremented, and reset. Use both useState and useReducer for state management.","archived":false,"fork":false,"pushed_at":"2024-08-14T05:45:17.000Z","size":38,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-07T06:18:58.684Z","etag":null,"topics":["hooks","react","state-management","typescript","usereducer","usestate"],"latest_commit_sha":null,"homepage":"","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CamiloPinzon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-14T04:44:32.000Z","updated_at":"2025-02-24T23:16:47.000Z","dependencies_parsed_at":"2024-08-14T06:50:23.297Z","dependency_job_id":null,"html_url":"https://github.com/CamiloPinzon/State-Management","commit_stats":null,"previous_names":["camilopinzon/state-management"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CamiloPinzon/State-Management","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CamiloPinzon%2FState-Management","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CamiloPinzon%2FState-Management/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CamiloPinzon%2FState-Management/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CamiloPinzon%2FState-Management/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CamiloPinzon","download_url":"https://codeload.github.com/CamiloPinzon/State-Management/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CamiloPinzon%2FState-Management/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32731246,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T02:14:30.463Z","status":"ssl_error","status_checked_at":"2026-05-07T02:14:29.405Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hooks","react","state-management","typescript","usereducer","usestate"],"created_at":"2024-11-07T18:08:54.229Z","updated_at":"2026-05-07T09:31:58.480Z","avatar_url":"https://github.com/CamiloPinzon.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Counter Example with Vite and TypeScript\n\nThis project demonstrates two approaches to building a simple counter application in React, created with Vite and TypeScript:\n\n1. **Main Branch:** Using the `useState` hook for state management.\n2. **useReducer Branch:** Using the `useReducer` hook for state management.\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Branches Overview](#branches-overview)\n- [Getting Started](#getting-started)\n  - [Prerequisites](#prerequisites)\n  - [Installation](#installation)\n  - [Running the Project](#running-the-project)\n  - [Switching Between Branches](#switching-between-branches)\n- [Project Structure](#project-structure)\n- [Usage](#usage)\n- [Learn More](#learn-more)\n- [License](#license)\n\n## Introduction\n\nThis project showcases how to implement a simple counter application using two different React hooks for state management. The counter allows users to increment, decrement, and reset the count value.\n\nThe project is built using Vite, a fast build tool that offers an optimized development experience, and TypeScript, which provides type safety in JavaScript applications.\n\n## Branches Overview\n\n- **Main Branch (useState):** This branch uses the `useState` hook to manage the counter's state. It's straightforward and ideal for simpler state management needs.\n  \n- **useReducer Branch:** This branch uses the `useReducer` hook, which is more suitable for complex state management scenarios. The reducer logic is placed in a separate file to demonstrate better code organization.\n\n## Getting Started\n\n### Prerequisites\n\n- Node.js (v14 or later)\n- npm or Yarn\n\n### Installation\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/CamiloPinzon/State-Management.git\n   cd State-Management\n   ```\n\n2. Install dependencies:\n\n   ```bash\n   npm install\n   ```\n\n   or\n\n   ```bash\n   yarn install\n   ```\n\n### Running the Project\n\nTo run the project on the main branch (useState):\n\n```bash\nnpm run dev\n```\n\nor\n\n```bash\nyarn dev\n```\n\nThis will start the Vite development server. By default, the project will be available at `http://localhost:5173`. You can view the project by navigating to this URL in your web browser.\n\n### Switching Between Branches\n\nTo switch to the `useReducer` branch:\n\n```bash\ngit checkout useReducer\n```\n\nThen, start the development server again:\n\n```bash\nnpm run dev\n```\n\nor\n\n```bash\nyarn dev\n```\n\n## Project Structure\n\n```plaintext\nreact-counter-example/\n├── src/\n│   ├── components/\n│   │   └── Counter.tsx\n│   ├── reducers/  (only in useReducer branch)\n│   │   └── counterReducer.ts\n│   ├── App.tsx\n│   ├── main.tsx\n│   └── index.css\n├── .gitignore\n├── index.html\n├── package.json\n├── tsconfig.json\n└── vite.config.ts\n```\n\n- **Main Branch (useState):**\n  - The `Counter` component handles all state management with `useState`.\n\n- **useReducer Branch:**\n  - The `Counter` component utilizes `useReducer` for state management.\n  - The reducer logic is moved to a separate file (`counterReducer.ts`) under the `reducers` directory.\n\n## Usage\n\n- **Increment:** Increases the count by 1.\n- **Decrement:** Decreases the count by 1.\n- **Reset:** Resets the count to 0.\n\n### Example (useState Approach):\n\n```tsx\nconst increment = () =\u003e setCount(prevCount =\u003e prevCount + 1);\n```\n\n### Example (useReducer Approach):\n\n```tsx\nconst increment = () =\u003e dispatch({ type: 'increment' });\n```\n\n## Learn More\n\nTo learn more about the technologies used in this project, check out the following resources:\n\n- [Vite Documentation](https://vitejs.dev/guide/)\n- [React Documentation](https://reactjs.org/docs/getting-started.html)\n- [TypeScript Documentation](https://www.typescriptlang.org/docs/)\n\n## License\n\nThis project is licensed under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcamilopinzon%2Fstate-management","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcamilopinzon%2Fstate-management","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcamilopinzon%2Fstate-management/lists"}