├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── custom.md │ └── feature_request.md ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── dist ├── index.es.js ├── index.es.js.map ├── index.js └── index.js.map ├── logo.png ├── package.json ├── rollup.config.js ├── src ├── .eslintrc ├── hooks.js └── index.js └── yarn.lock /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production build 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at saeed_dev@yahoo.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Just fork this repo. Then, if you have some amazing idea, implement it and then submit a PR. 2 | I will review it and then merge it if it's up-to-the-par. Otherwise, I will let you know. 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 saeed_dev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 📈 Statistics for 🦠 COVID19 harnessing the power of ⚛️ React Hooks 10 | 11 | [![NPM](https://img.shields.io/npm/v/react-covid-hooks.svg)](https://www.npmjs.com/package/react-covid-hooks) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/iamsaeeddev/react-covid-hooks/issues) 12 |

13 |
14 | 15 | 16 | # react-covid-hooks 17 | > 📈 Get Statistics for 🦠 COVID19 Harnessing the Power of ⚛️ React Hooks 18 | 19 | - 🚀 get overall statistics, country-wise, state-wise (US) and statistics till yesterday 20 | - 🦠 get overall statistics for COVID19 21 | - 🇺🇸 get updated statistics for all US states 22 | - 🗺️ get statistics for all countries of the world 23 | - ⏮️ get updates statistics for yesterday 24 | - 📈 For overall statistics, Data : updated (Time Stamp), cases, todayCases, deaths, todayDeaths, recovered, active, critical, casesPerOneMillion, deathsPerOneMillion, tests, testsPerOneMillion, affectedCountries 25 | - 📈 For all states of the US, Data : state, cases, todayCases, deaths, todayDeaths, active, tests, testsPerOneMillion 26 | - 📈 For all countries of the world, Data : country, countryInfo, updated, cases, todayCases, deaths, todayDeaths, recovered, active, critical, casesPerOneMillion, deathsPerOneMillion, tests, testsPerOneMillion 27 | - 📈 For statistics till yesterday, Data : country, countryInfo, updated, cases, todayCases, deaths, todayDeaths, recovered, active, critical, casesPerOneMillion, deathsPerOneMillion, tests, testsPerOneMillion 28 | 29 | 30 | 31 | ## 📥 Install 32 | 33 | ``` 34 | npm install react-covid-hooks 35 | ``` 36 | 37 | 38 | ## 💅 Usage 39 | 40 | ### 📈 All Statistics 41 | 42 | ``` 43 | import { useAll } from 'react-covid-hooks'; 44 | 45 | const allStats = useAll(); 46 | ``` 47 | 48 | 49 | ### 📈 Country-wise Statistics 50 | 51 | ``` 52 | import { useCountries } from 'react-covid-hooks'; 53 | 54 | const allCountries = useCountries(); 55 | ``` 56 | 57 | 58 | ### 📈 State-wise Statistics 59 | 60 | ``` 61 | import { useStates } from 'react-covid-hooks'; 62 | 63 | const allStates = useStates(); 64 | ``` 65 | 66 | 67 | ### 📈 Statistics till Yesterday 68 | 69 | ``` 70 | import { useYesterday } from 'react-covid-hooks'; 71 | 72 | const yesterdayStats = useYesterday(); 73 | ``` 74 | 75 | 76 | 77 | ## 🗒️ Changelog 78 | 79 | Changelog exists in the [releases](https://github.com/mrsaeeddev/react-covid-hooks/releases) tab 80 | 81 | 82 | 83 | ## ⚙️ Contributions 84 | 85 | Contributions/PRs/Feedback is welcome 86 | 87 | 88 | 89 | ## 📔 License 90 | 91 | This library is release under [MIT License](https://github.com/mrsaeeddev/react-covid-hooks/blob/master/LICENSE) 92 | 93 | 94 | 95 | ## ⛓️ Connect 96 | 97 |
98 |

GitHub @mrsaeeddev  💻 Want to get updated on latest trends in Open Source? Follow me on GitHub!

99 |

Twitter @mrsaeeddev  🐦 Want to get help or discuss something? Get connected on Twitter!

100 |

DEV @mrsaeeddev  📖 Want to read my articles? Visit my DEV blog!

101 |

LinkedIn @mrsaeeddev  🏢 Want to see my professional journey? Let's Connect on LinkedIn

102 |
103 | 104 |
105 | -------------------------------------------------------------------------------- /dist/index.es.js: -------------------------------------------------------------------------------- 1 | import { useState, useEffect } from 'react'; 2 | 3 | const useAll = () => { 4 | const [allStats, setAllStats] = useState([]); 5 | const [apiEndPoint, setApiEndPoint] = useState("https://corona.lmao.ninja/"); 6 | useEffect(() => { 7 | fetch(apiEndPoint + "all").then(res => { 8 | res.json().then(data => { 9 | setAllStats(data); 10 | }); 11 | }); 12 | }, []); 13 | return allStats; 14 | }; 15 | const useStates = () => { 16 | const [stateStats, setStateStats] = useState([]); 17 | const [apiEndPoint, setApiEndPoint] = useState("https://corona.lmao.ninja/"); 18 | useEffect(() => { 19 | fetch(apiEndPoint + "states").then(res => { 20 | res.json().then(data => setStateStats(data)); 21 | }); 22 | }, []); 23 | return stateStats; 24 | }; 25 | const useCountries = () => { 26 | const [countryStats, setCountryStats] = useState([]); 27 | const [apiEndPoint, setApiEndPoint] = useState("https://corona.lmao.ninja/"); 28 | useEffect(() => { 29 | fetch(apiEndPoint + "countries").then(res => { 30 | res.json().then(data => setCountryStats(data)); 31 | }); 32 | }, []); 33 | return countryStats; 34 | }; 35 | const useYesterday = () => { 36 | const [yesterdayStats, setYesterdayStats] = useState([]); 37 | const [apiEndPoint, setApiEndPoint] = useState("https://corona.lmao.ninja/"); 38 | useEffect(() => { 39 | fetch(apiEndPoint + "yesterday").then(res => { 40 | res.json().then(data => setYesterdayStats(data)); 41 | }); 42 | }, []); 43 | return yesterdayStats; 44 | }; 45 | 46 | export { useAll, useCountries, useStates, useYesterday }; 47 | //# sourceMappingURL=index.es.js.map 48 | -------------------------------------------------------------------------------- /dist/index.es.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.es.js","sources":["../src/hooks.js"],"sourcesContent":["import { useState, useEffect } from 'react';\n\nexport const useAll = () => {\n const [allStats, setAllStats] = useState([]);\n const [apiEndPoint, setApiEndPoint] = useState(\"https://corona.lmao.ninja/\");\n\n useEffect(() => {\n fetch(apiEndPoint+\"all\").then((res)=>{\n res.json().then((data)=>{\n setAllStats(data)\n })\n })\n },[]);\n\n return allStats\n} \n\nexport const useStates = () => {\n const [stateStats, setStateStats] = useState([]);\n const [apiEndPoint, setApiEndPoint] = useState(\"https://corona.lmao.ninja/\");\n\n useEffect(() => {\n fetch(apiEndPoint+\"states\").then((res)=>{\n res.json().then(data=>(\n setStateStats(data)\n ))\n })\n },[]);\n\n return stateStats\n}\n\nexport const useCountries = () => {\n const [countryStats, setCountryStats] = useState([]);\n const [apiEndPoint, setApiEndPoint] = useState(\"https://corona.lmao.ninja/\");\n\n useEffect(() => {\n fetch(apiEndPoint+\"countries\").then((res)=>{\n res.json().then(data=>(\n setCountryStats(data)\n ))\n })\n },[]);\n \n return countryStats\n}\n\nexport const useYesterday = () => {\n const [yesterdayStats, setYesterdayStats] = useState([]);\n const [apiEndPoint, setApiEndPoint] = useState(\"https://corona.lmao.ninja/\");\n\n useEffect(() => {\n fetch(apiEndPoint+\"yesterday\").then((res)=>{\n res.json().then(data=>(\n setYesterdayStats(data)\n ))\n })\n },[]);\n \n return yesterdayStats\n}\n"],"names":["useAll","allStats","setAllStats","useState","apiEndPoint","setApiEndPoint","useEffect","fetch","then","res","json","data","useStates","stateStats","setStateStats","useCountries","countryStats","setCountryStats","useYesterday","yesterdayStats","setYesterdayStats"],"mappings":";;MAEaA,MAAM,GAAG,MAAM;AAC1B,QAAM,CAACC,QAAD,EAAWC,WAAX,IAA0BC,QAAQ,CAAC,EAAD,CAAxC;AACA,QAAM,CAACC,WAAD,EAAcC,cAAd,IAAgCF,QAAQ,CAAC,4BAAD,CAA9C;AAEAG,EAAAA,SAAS,CAAC,MAAM;AACdC,IAAAA,KAAK,CAACH,WAAW,GAAC,KAAb,CAAL,CAAyBI,IAAzB,CAA+BC,GAAD,IAAO;AACnCA,MAA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9C;AAEAG,EAAAA,SAAS,CAAC,MAAM;AACdC,IAAAA,KAAK,CAACH,WAAW,GAAC,WAAb,CAAL,CAA+BI,IAA/B,CAAqCC,GAAD,IAAO;AACzCA,MAAAA,GAAG,CAACC,IAAJ,GAAWF,IAAX,CAAgBG,IAAI,IAClBS,iBAAiB,CAACT,IAAD,CADnB;AAGD,KAJD;AAKD,GANQ,EAMP,EANO,CAAT;AAQA,SAAOQ,cAAP;AACD;;;;"} -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { value: true }); 4 | 5 | var react = require('react'); 6 | 7 | const useAll = () => { 8 | const [allStats, setAllStats] = react.useState([]); 9 | const [apiEndPoint, setApiEndPoint] = react.useState("https://corona.lmao.ninja/"); 10 | react.useEffect(() => { 11 | fetch(apiEndPoint + "all").then(res => { 12 | res.json().then(data => { 13 | setAllStats(data); 14 | }); 15 | }); 16 | }, []); 17 | return allStats; 18 | }; 19 | const useStates = () => { 20 | const [stateStats, setStateStats] = react.useState([]); 21 | const [apiEndPoint, setApiEndPoint] = react.useState("https://corona.lmao.ninja/"); 22 | react.useEffect(() => { 23 | fetch(apiEndPoint + "states").then(res => { 24 | res.json().then(data => setStateStats(data)); 25 | }); 26 | }, []); 27 | return stateStats; 28 | }; 29 | const useCountries = () => { 30 | const [countryStats, setCountryStats] = react.useState([]); 31 | const [apiEndPoint, setApiEndPoint] = react.useState("https://corona.lmao.ninja/"); 32 | react.useEffect(() => { 33 | fetch(apiEndPoint + "countries").then(res => { 34 | res.json().then(data => setCountryStats(data)); 35 | }); 36 | }, []); 37 | return countryStats; 38 | }; 39 | const useYesterday = () => { 40 | const [yesterdayStats, setYesterdayStats] = react.useState([]); 41 | const [apiEndPoint, setApiEndPoint] = react.useState("https://corona.lmao.ninja/"); 42 | react.useEffect(() => { 43 | fetch(apiEndPoint + "yesterday").then(res => { 44 | res.json().then(data => setYesterdayStats(data)); 45 | }); 46 | }, []); 47 | return yesterdayStats; 48 | }; 49 | 50 | exports.useAll = useAll; 51 | exports.useCountries = useCountries; 52 | exports.useStates = useStates; 53 | exports.useYesterday = useYesterday; 54 | //# sourceMappingURL=index.js.map 55 | -------------------------------------------------------------------------------- /dist/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sources":["../src/hooks.js"],"sourcesContent":["import { useState, useEffect } from 'react';\n\nexport const useAll = () => {\n const [allStats, setAllStats] = useState([]);\n const [apiEndPoint, setApiEndPoint] = useState(\"https://corona.lmao.ninja/\");\n\n useEffect(() => {\n fetch(apiEndPoint+\"all\").then((res)=>{\n res.json().then((data)=>{\n setAllStats(data)\n })\n })\n },[]);\n\n return allStats\n} \n\nexport const useStates = () => {\n const [stateStats, setStateStats] = useState([]);\n const [apiEndPoint, setApiEndPoint] = useState(\"https://corona.lmao.ninja/\");\n\n useEffect(() => {\n fetch(apiEndPoint+\"states\").then((res)=>{\n res.json().then(data=>(\n setStateStats(data)\n ))\n })\n },[]);\n\n return stateStats\n}\n\nexport const useCountries = () => {\n const [countryStats, setCountryStats] = useState([]);\n const [apiEndPoint, setApiEndPoint] = useState(\"https://corona.lmao.ninja/\");\n\n useEffect(() => {\n fetch(apiEndPoint+\"countries\").then((res)=>{\n res.json().then(data=>(\n setCountryStats(data)\n ))\n })\n },[]);\n \n return countryStats\n}\n\nexport const useYesterday = () => {\n const [yesterdayStats, setYesterdayStats] = useState([]);\n const [apiEndPoint, setApiEndPoint] = useState(\"https://corona.lmao.ninja/\");\n\n useEffect(() => {\n fetch(apiEndPoint+\"yesterday\").then((res)=>{\n res.json().then(data=>(\n setYesterdayStats(data)\n ))\n })\n },[]);\n \n return yesterdayStats\n}\n"],"names":["useAll","allStats","setAllStats","useState","apiEndPoint","setApiEndPoint","useEffect","fetch","then","res","json","data","useStates","stateStats","setStateStats","useCountries","countryStats","setCountryStats","useYesterday","yesterdayStats","setYesterdayStats"],"mappings":";;;;;;MAEaA,MAAM,GAAG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,CAAgBG,IAAI,IAClBM,eAAe,CAACN,IAAD,CADjB;AAGD,KAJD;AAKD,GANQ,EAMP,EANO,CAAT;AAQA,SAAOK,YAAP;AACD;MAEYE,YAAY,GAAG,MAAM;AAChC,QAAM,CAACC,cAAD,EAAiBC,iBAAjB,IAAsCjB,cAAQ,CAAC,EAAD,CAApD;AACA,QAAM,CAACC,WAAD,EAAcC,cAAd,IAAgCF,cAAQ,CAAC,4BAAD,CAA9C;AAEAG,EAAAA,eAAS,CAAC,MAAM;AACdC,IAAAA,KAAK,CAACH,WAAW,GAAC,WAAb,CAAL,CAA+BI,IAA/B,CAAqCC,GAAD,IAAO;AACzCA,MAAAA,GAAG,CAACC,IAAJ,GAAWF,IAAX,CAAgBG,IAAI,IAClBS,iBAAiB,CAACT,IAAD,CADnB;AAGD,KAJD;AAKD,GANQ,EAMP,EANO,CAAT;AAQA,SAAOQ,cAAP;AACD;;;;;;;"} -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrsaeeddev/react-covid-hooks/84907a5fdb6bd3683762f6aca5644e43f294919f/logo.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-covid-hooks", 3 | "version": "1.4.0", 4 | "description": "📈 Get Statistics for 🦠 COVID19 Harnessing the Power of ⚛️ React Hooks", 5 | "author": "iamsaeeddev", 6 | "license": "MIT", 7 | "repository": "iamsaeeddev/react-covid-hooks", 8 | "main": "dist/index.js", 9 | "module": "dist/index.es.js", 10 | "jsnext:main": "dist/index.es.js", 11 | "engines": { 12 | "node": ">=8", 13 | "npm": ">=5" 14 | }, 15 | "bugs": { 16 | "url": "https://github.com/iamsaeeddev/react-covid-hooks/issues" 17 | }, 18 | "homepage": "https://github.com/iamsaeeddev/react-covid-hooks", 19 | "keywords": [ 20 | "corona", 21 | "covid-19", 22 | "covid19", 23 | "coronavirus", 24 | "virus", 25 | "cdc" 26 | ], 27 | "scripts": { 28 | "test": "cross-env CI=1 react-scripts test --env=jsdom", 29 | "test:watch": "react-scripts test --env=jsdom", 30 | "build": "rollup -c", 31 | "start": "rollup -c -w", 32 | "prepare": "yarn run build", 33 | "predeploy": "cd example && yarn install && yarn run build", 34 | "deploy": "gh-pages -d example/build" 35 | }, 36 | "peerDependencies": { 37 | "react": "^16.9.0" 38 | }, 39 | "devDependencies": { 40 | "@babel/core": "^7.0.0", 41 | "@babel/plugin-external-helpers": "^7.0.0", 42 | "@babel/plugin-proposal-class-properties": "^7.0.0", 43 | "@babel/plugin-proposal-decorators": "^7.0.0", 44 | "@babel/plugin-proposal-do-expressions": "^7.0.0", 45 | "@babel/plugin-proposal-export-default-from": "^7.0.0", 46 | "@babel/plugin-proposal-export-namespace-from": "^7.0.0", 47 | "@babel/plugin-proposal-function-bind": "^7.0.0", 48 | "@babel/plugin-proposal-function-sent": "^7.0.0", 49 | "@babel/plugin-proposal-json-strings": "^7.0.0", 50 | "@babel/plugin-proposal-logical-assignment-operators": "^7.0.0", 51 | "@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0", 52 | "@babel/plugin-proposal-numeric-separator": "^7.0.0", 53 | "@babel/plugin-proposal-optional-chaining": "^7.0.0", 54 | "@babel/plugin-proposal-pipeline-operator": "^7.0.0", 55 | "@babel/plugin-proposal-throw-expressions": "^7.0.0", 56 | "@babel/plugin-syntax-dynamic-import": "^7.0.0", 57 | "@babel/plugin-syntax-import-meta": "^7.0.0", 58 | "@babel/preset-env": "^7.0.0", 59 | "@babel/preset-react": "^7.0.0", 60 | "@testing-library/react-hooks": "^3.2.1", 61 | "babel-eslint": "^10.0.1", 62 | "cross-env": "^5.2.0", 63 | "eslint": "5.16.0", 64 | "eslint-config-standard": "^11.0.0", 65 | "eslint-config-standard-react": "^6.0.0", 66 | "eslint-plugin-import": "^2.13.0", 67 | "eslint-plugin-node": "^7.0.1", 68 | "eslint-plugin-promise": "^4.0.0", 69 | "eslint-plugin-react": "^7.10.0", 70 | "eslint-plugin-standard": "^3.1.0", 71 | "gh-pages": "^2.0.1", 72 | "react": "^16.9.0", 73 | "react-scripts": "^3.4.0", 74 | "react-test-renderer": "^16.9.0", 75 | "rollup": "^1.1.2", 76 | "rollup-plugin-babel": "^4.3.2", 77 | "rollup-plugin-commonjs": "^9.2.0", 78 | "rollup-plugin-node-resolve": "^4.0.0", 79 | "rollup-plugin-peer-deps-external": "^2.2.0", 80 | "rollup-plugin-url": "^2.1.0" 81 | } 82 | } -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import babel from 'rollup-plugin-babel' 2 | import commonjs from 'rollup-plugin-commonjs' 3 | import external from 'rollup-plugin-peer-deps-external' 4 | import resolve from 'rollup-plugin-node-resolve' 5 | import url from 'rollup-plugin-url' 6 | 7 | import pkg from './package.json' 8 | 9 | export default { 10 | input: 'src/index.js', 11 | output: [ 12 | { 13 | file: pkg.main, 14 | format: 'cjs', 15 | sourcemap: true 16 | }, 17 | { 18 | file: pkg.module, 19 | format: 'es', 20 | sourcemap: true 21 | } 22 | ], 23 | plugins: [ 24 | external(), 25 | url({ exclude: ['**/*.svg'] }), 26 | babel({ 27 | exclude: 'node_modules/**' 28 | }), 29 | resolve(), 30 | commonjs() 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /src/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "jest": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/hooks.js: -------------------------------------------------------------------------------- 1 | import { useState, useEffect } from 'react'; 2 | 3 | export const useAll = () => { 4 | const [allStats, setAllStats] = useState([]); 5 | const [apiEndPoint, setApiEndPoint] = useState("https://corona.lmao.ninja/"); 6 | 7 | useEffect(() => { 8 | fetch(apiEndPoint+"all").then((res)=>{ 9 | res.json().then((data)=>{ 10 | setAllStats(data) 11 | }) 12 | }) 13 | },[]); 14 | 15 | return allStats 16 | } 17 | 18 | export const useStates = () => { 19 | const [stateStats, setStateStats] = useState([]); 20 | const [apiEndPoint, setApiEndPoint] = useState("https://corona.lmao.ninja/"); 21 | 22 | useEffect(() => { 23 | fetch(apiEndPoint+"states").then((res)=>{ 24 | res.json().then(data=>( 25 | setStateStats(data) 26 | )) 27 | }) 28 | },[]); 29 | 30 | return stateStats 31 | } 32 | 33 | export const useCountries = () => { 34 | const [countryStats, setCountryStats] = useState([]); 35 | const [apiEndPoint, setApiEndPoint] = useState("https://corona.lmao.ninja/"); 36 | 37 | useEffect(() => { 38 | fetch(apiEndPoint+"countries").then((res)=>{ 39 | res.json().then(data=>( 40 | setCountryStats(data) 41 | )) 42 | }) 43 | },[]); 44 | 45 | return countryStats 46 | } 47 | 48 | export const useYesterday = () => { 49 | const [yesterdayStats, setYesterdayStats] = useState([]); 50 | const [apiEndPoint, setApiEndPoint] = useState("https://corona.lmao.ninja/"); 51 | 52 | useEffect(() => { 53 | fetch(apiEndPoint+"yesterday").then((res)=>{ 54 | res.json().then(data=>( 55 | setYesterdayStats(data) 56 | )) 57 | }) 58 | },[]); 59 | 60 | return yesterdayStats 61 | } 62 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | export { useAll, useStates, useCountries, useYesterday } from './hooks'; --------------------------------------------------------------------------------