{"id":15177631,"url":"https://github.com/arnobt78/shopmate-react-context-reducer-webpage","last_synced_at":"2025-02-23T14:21:32.658Z","repository":{"id":255388098,"uuid":"849449388","full_name":"arnobt78/Shopmate-React-Context-Reducer-Webpage","owner":"arnobt78","description":"Shopmate is a demo React E-Commerce Web Application (Global Level State Application), using React \"useContext\" and \"useReducer\" features. React Core, Hooks, Routing, HTML, CSS, Responsive Screen, Context, and Reducers functionalities have been used in this project and deployed on Netlify.","archived":false,"fork":false,"pushed_at":"2024-08-29T16:51:31.000Z","size":465,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-05T02:41:45.292Z","etag":null,"topics":["css","e-commerce","hmtl","javascript","react","react-components","react-context","react-hooks","react-reducers","react-router","react-router-dom","reactjs"],"latest_commit_sha":null,"homepage":"https://shopmate-cr-arnob.netlify.app","language":"JavaScript","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/arnobt78.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-29T16:03:00.000Z","updated_at":"2024-08-29T16:51:35.000Z","dependencies_parsed_at":"2024-08-29T18:04:08.209Z","dependency_job_id":null,"html_url":"https://github.com/arnobt78/Shopmate-React-Context-Reducer-Webpage","commit_stats":null,"previous_names":["arnobt78/shopmate-react-context-reducer-webpage"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobt78%2FShopmate-React-Context-Reducer-Webpage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobt78%2FShopmate-React-Context-Reducer-Webpage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobt78%2FShopmate-React-Context-Reducer-Webpage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobt78%2FShopmate-React-Context-Reducer-Webpage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arnobt78","download_url":"https://codeload.github.com/arnobt78/Shopmate-React-Context-Reducer-Webpage/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240324912,"owners_count":19783577,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["css","e-commerce","hmtl","javascript","react","react-components","react-context","react-hooks","react-reducers","react-router","react-router-dom","reactjs"],"created_at":"2024-09-27T14:41:28.449Z","updated_at":"2025-02-23T14:21:32.627Z","avatar_url":"https://github.com/arnobt78.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003cimg width=\"1254\" alt=\"Screenshot 2024-08-29 at 18 48 19\" src=\"https://github.com/user-attachments/assets/c0f1abe9-ade8-4998-aa5a-08db61a9e2ca\"\u003e \u003cimg width=\"1255\" alt=\"Screenshot 2024-08-29 at 18 48 40\" src=\"https://github.com/user-attachments/assets/7ae1bb28-10c3-4e5e-88cd-e8cd24f334a6\"\u003e\n\n## Shopmate-React-Context-Reducer-Webpage\n\nShopmate is a demo React E-Commerce Web Application (Global Level State Application), using React **\"useContext\"** and **\"useReducer\"** features. React Core, Hooks, Routing, HTML, CSS, Responsive Screen, Context, and Reducers functionalities have been used in this project and deployed on Netlify.\n\n**Note:** \"useContext\" and \"useReducer\" have been employed in this React project; \"Redux\" and \"Redux-Toolkit\" have not been used here.\n\n**This webpage can be seen by using this URL:** https://shopmate-cr-arnob.netlify.app\n\n## To Install Dependences\n\nBefore launching this web application, be sure to install all required dependencies, which are listed in the package.json file.\n\nTo install all dependences, run this command from your project folder: `npm install`\n\n## To Install NodeJS\n\nMake sure you have NodeJS installed in your machine first, The installation instructions are here: https://nodejs.org/en/\n\n## To Install React-Router \n\nOpen up your terminal and bootstrap a new React app by: `npx create-react-app`\n\nThen go to that project folder, and write this command via terminal from your project folder: `npm install react-router-dom`\n\n(To check for more details about React-Router, please visit: https://reactrouter.com/en/main )\n\n## About React Context and Reducers\n\n- **useContext**: Global State Management\n\nUsed to save state globally so the state is available globally in our application.\n\n- **useReducers**: Perform Actions On Global State\n\nAllow us to manage complex state logic.\n\nVocab,\n\n- `context` - an API given to us by React, allowing for the passing of information to child components without the use of props\n  \n- `reducer` - a pure function, accepting a state \u0026 action, and returning a new state\n  \n- `action` - an object literal, which describes a change to the state\n  \n- `useContext` - a react hook, that allows functional components to take advantage of the context API\n  \n- `useReducer` - a react hook, used in place of `useState`, generally for more complex state\n  \n- `dispatch` - a function returned to us by `useReducer`, which sends action objects to the reducer function\n\n**context/CartContext.js**\n\n1. Create a ‘context’ folder with ‘CartContext.js’ file inside it\n\n2. Define initialState\n\n3. Create CartContext using createContext with initialState\n\n**context/cartReducer.js**\n\n1. Create a ‘reducer’ folder with ‘cartReducer.js’ inside it\n\n2. Create cartReducer function with parameters as state and action\n\n3. Define all operations as switch statements inside the cartReducer\n\n**context/CartContext.js**\n\n1. Create CartProvider accessing the children\n\n2. Access state and dispatch using useReducer with cartReducer and initialState\n\n3. Define function for each possible operation\n\n4. Use dispatch to execute the operation along with type and payload\n\n5. Return the CartContext.Provider with children and prop value\nValues that you want to access inside the entire application\n\n6. Create useCart function, \n- Define context using useContext(CartContext)\n- Return the context\n\n**App.js**\n\n1. Wrap entire App with CartProvider\n\n**CartCard.js**\n\n1. Access all values using useCart()\n\n2. Add a condition to restrict ‘Add To Cart’ for one-time use for each product \n\n**Cart.js**\n\n1. Access cart items and total using useCart()\n\n## Available Scripts\n\nIn the project directory, you can run:\n\n### `npm start`\n\nRuns the app in the development mode.\\\nOpen [http://localhost:3000](http://localhost:3000) to view it in your browser.\n\nThe page will reload when you make changes.\\\nYou may also see any lint errors in the console.\n\n### `npm test`\n\nLaunches the test runner in the interactive watch mode.\\\nSee the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.\n\n### `npm run build`\n\nBuilds the app for production to the `build` folder.\\\nIt correctly bundles React in production mode and optimizes the build for the best performance.\n\nThe build is minified and the filenames include the hashes.\\\nYour app is ready to be deployed!\n\nSee the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.\n\n### `npm run eject`\n\n**Note: this is a one-way operation. Once you `eject`, you can't go back!**\n\nIf you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.\n\nInstead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.\n\nYou don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.\n\n## Learn More\n\nYou can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).\n\nTo learn React, check out the [React documentation](https://reactjs.org/).\n\n### Code Splitting\n\nThis section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)\n\n### Analyzing the Bundle Size\n\nThis section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)\n\n### Making a Progressive Web App\n\nThis section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)\n\n### Advanced Configuration\n\nThis section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)\n\n### Deployment\n\nThis section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)\n\n### `npm run build` fails to minify\n\nThis section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnobt78%2Fshopmate-react-context-reducer-webpage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farnobt78%2Fshopmate-react-context-reducer-webpage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnobt78%2Fshopmate-react-context-reducer-webpage/lists"}