├── .eslintcache ├── .gitignore ├── README.md ├── package.json ├── public ├── favicon.ico ├── hv-taplist.json ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt ├── src ├── App.css ├── App.test.tsx ├── App.tsx ├── CustomHookComponent.tsx ├── EvenMoreReactComponent.tsx ├── UseContextComponent.tsx ├── UseEffectComponent.tsx ├── UseReducerComponent.tsx ├── UseRefComponent.tsx ├── UseStateComponent.tsx ├── index.css ├── index.tsx ├── logo.svg ├── react-app-env.d.ts ├── reportWebVitals.ts ├── setupTests.ts └── store.ts ├── tsconfig.json └── yarn.lock /.eslintcache: -------------------------------------------------------------------------------- 1 | [{"/Users/jherr/tmp/ts-hooks/src/App.tsx":"1","/Users/jherr/tmp/ts-hooks/src/UseStateComponent.tsx":"2","/Users/jherr/tmp/ts-hooks/src/UseEffectComponent.tsx":"3","/Users/jherr/tmp/ts-hooks/src/UseContextComponent.tsx":"4","/Users/jherr/tmp/ts-hooks/src/UseReducerComponent.tsx":"5","/Users/jherr/tmp/ts-hooks/src/UseRefComponent.tsx":"6","/Users/jherr/tmp/ts-hooks/src/CustomHookComponent.tsx":"7","/Users/jherr/tmp/ts-hooks/src/EvenMoreReactComponent.tsx":"8"},{"size":876,"mtime":1612123882447,"results":"9","hashOfConfig":"10"},{"size":530,"mtime":1612121214991,"results":"11","hashOfConfig":"10"},{"size":345,"mtime":1612121576147,"results":"12","hashOfConfig":"10"},{"size":752,"mtime":1612122141941,"results":"13","hashOfConfig":"10"},{"size":1220,"mtime":1612122741955,"results":"14","hashOfConfig":"10"},{"size":191,"mtime":1612122882895,"results":"15","hashOfConfig":"10"},{"size":1112,"mtime":1612123794708,"results":"16","hashOfConfig":"10"},{"size":688,"mtime":1612124756766,"results":"17","hashOfConfig":"10"},{"filePath":"18","messages":"19","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"18xto4y",{"filePath":"20","messages":"21","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"22","messages":"23","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"24","messages":"25","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"26","messages":"27","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"28","messages":"29","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"30","messages":"31","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"32","messages":"33","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/jherr/tmp/ts-hooks/src/App.tsx",[],"/Users/jherr/tmp/ts-hooks/src/UseStateComponent.tsx",[],"/Users/jherr/tmp/ts-hooks/src/UseEffectComponent.tsx",[],"/Users/jherr/tmp/ts-hooks/src/UseContextComponent.tsx",[],"/Users/jherr/tmp/ts-hooks/src/UseReducerComponent.tsx",[],"/Users/jherr/tmp/ts-hooks/src/UseRefComponent.tsx",[],"/Users/jherr/tmp/ts-hooks/src/CustomHookComponent.tsx",[],"/Users/jherr/tmp/ts-hooks/src/EvenMoreReactComponent.tsx",[]] -------------------------------------------------------------------------------- /.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 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `yarn start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `yarn test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `yarn build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `yarn eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If 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. 37 | 38 | Instead, 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. 39 | 40 | You 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. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ts-hooks", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.11.4", 7 | "@testing-library/react": "^11.1.0", 8 | "@testing-library/user-event": "^12.1.10", 9 | "@types/jest": "^26.0.15", 10 | "@types/node": "^12.0.0", 11 | "@types/react": "^16.9.53", 12 | "@types/react-dom": "^16.9.8", 13 | "react": "^17.0.1", 14 | "react-dom": "^17.0.1", 15 | "react-scripts": "4.0.1", 16 | "typescript": "^4.0.3", 17 | "web-vitals": "^0.2.4" 18 | }, 19 | "scripts": { 20 | "start": "react-scripts start", 21 | "build": "react-scripts build", 22 | "test": "react-scripts test", 23 | "eject": "react-scripts eject" 24 | }, 25 | "eslintConfig": { 26 | "extends": [ 27 | "react-app", 28 | "react-app/jest" 29 | ] 30 | }, 31 | "browserslist": { 32 | "production": [ 33 | ">0.2%", 34 | "not dead", 35 | "not op_mini all" 36 | ], 37 | "development": [ 38 | "last 1 chrome version", 39 | "last 1 firefox version", 40 | "last 1 safari version" 41 | ] 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jherr/ts-hooks/28ab09e250ca97e2693a49838be6e7008b344e71/public/favicon.ico -------------------------------------------------------------------------------- /public/hv-taplist.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "beer", 4 | "producerName": "Revision", 5 | "beverageName": "Sparkle Muffin", 6 | "beverageColor": "#FFDC67", 7 | "beverageStyle": "New England IPA", 8 | "producerLocation": "Sparks, NV", 9 | "abv": 7, 10 | "ibu": 30, 11 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/58813a565e002c0f185bd0e5.png", 12 | "level": 27.027027027027028 13 | }, 14 | { 15 | "name": "beer", 16 | "producerName": "Breakside", 17 | "beverageName": "What Rough Beast", 18 | "beverageColor": "#FFE699", 19 | "beverageStyle": "Hazy IPA", 20 | "producerLocation": "Portland, OR", 21 | "abv": 7, 22 | "ibu": 55, 23 | "logo": "https://s3.amazonaws.com/digitalpourbeveragelogos/58c1b2255e002c0658f1ebc7.png", 24 | "level": 72.97297297297297 25 | }, 26 | { 27 | "name": "beer", 28 | "producerName": "Ruse", 29 | "beverageName": "Papyrus Iris", 30 | "beverageColor": "#EDC722", 31 | "beverageStyle": "Hazy IPA", 32 | "producerLocation": "Portland, OR", 33 | "abv": 6, 34 | "ibu": null, 35 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/56bcd0a85e002c0384342684.png", 36 | "level": 56.75675675675676 37 | }, 38 | { 39 | "name": "beer", 40 | "producerName": "Barley Brown's", 41 | "beverageName": "Pallet Jack", 42 | "beverageColor": "#EDBD22", 43 | "beverageStyle": "IPA", 44 | "producerLocation": "Baker City, OR", 45 | "abv": 7, 46 | "ibu": 70, 47 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/501233859294c3198c3fd2fb.png", 48 | "level": 94.5945945945946 49 | }, 50 | { 51 | "name": "beer", 52 | "producerName": "Boneyard", 53 | "beverageName": "RPM", 54 | "beverageColor": "#F7B100", 55 | "beverageStyle": "IPA", 56 | "producerLocation": "Bend, OR", 57 | "abv": 6, 58 | "ibu": 50, 59 | "logo": "https://s3.amazonaws.com/digitalpourbeveragelogos/501234409294c3198c3fd58b.png", 60 | "level": 2.7027027027027026 61 | }, 62 | { 63 | "name": "beer", 64 | "producerName": "Breakside", 65 | "beverageName": "Starstruck IPA", 66 | "beverageColor": "#F6F718", 67 | "beverageStyle": "West Coast India Pale Ale", 68 | "producerLocation": "Portland, OR", 69 | "abv": 6, 70 | "ibu": null, 71 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/5012337c9294c3198c3fd29e.png", 72 | "level": 86.48648648648648 73 | }, 74 | { 75 | "name": "beer", 76 | "producerName": "Grains of Wrath", 77 | "beverageName": "Grave Dancer", 78 | "beverageColor": "#EDC722", 79 | "beverageStyle": "Single Hop Mosaic IPA", 80 | "producerLocation": "Camas, WA", 81 | "abv": 6, 82 | "ibu": null, 83 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/589e2a075e002c0a2ce9067b.png", 84 | "level": 35.13513513513514 85 | }, 86 | { 87 | "name": "beer", 88 | "producerName": "Melvin", 89 | "beverageName": "2x4", 90 | "beverageColor": "#F7E026", 91 | "beverageStyle": "American Imperial IPA", 92 | "producerLocation": "Alpine, WY", 93 | "abv": 9, 94 | "ibu": 100, 95 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/552d84cc5e002c0d5c543143.png", 96 | "level": 40.54054054054054 97 | }, 98 | { 99 | "name": "beer", 100 | "producerName": "pFriem", 101 | "beverageName": "Pilsner", 102 | "beverageColor": "#F2E352", 103 | "beverageStyle": "Pilsner", 104 | "producerLocation": "Hood River, OR", 105 | "abv": 4, 106 | "ibu": 35, 107 | "logo": "https://s3.amazonaws.com/digitalpourbeveragelogos/518967d8fb890c111807def7.png", 108 | "level": 70.27027027027027 109 | }, 110 | { 111 | "name": "beer", 112 | "producerName": "Sunriver", 113 | "beverageName": "Rippin Pale Ale", 114 | "beverageColor": "#FFE800", 115 | "beverageStyle": "Pale Ale", 116 | "producerLocation": "Sunriver, OR", 117 | "abv": 6, 118 | "ibu": null, 119 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/5421c41dfb890e0808aeaef5.png", 120 | "level": 54.054054054054056 121 | }, 122 | { 123 | "name": "beer", 124 | "producerName": "Boss Rambler", 125 | "beverageName": "Pureé Vida", 126 | "beverageColor": "#F4F460", 127 | "beverageStyle": "Berliner Weisse Fruited", 128 | "producerLocation": "Bend, OR", 129 | "abv": 5, 130 | "ibu": null, 131 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/5b663ed7352726062026e68d.png", 132 | "level": 21.62162162162162 133 | }, 134 | { 135 | "name": "beer", 136 | "producerName": "Sunriver", 137 | "beverageName": "Deseo", 138 | "beverageColor": "#EBDE5E", 139 | "beverageStyle": "Mexican-Style Lager", 140 | "producerLocation": "Sunriver, OR", 141 | "abv": 5, 142 | "ibu": null, 143 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/5421c41dfb890e0808aeaef5.png", 144 | "level": 97.2972972972973 145 | }, 146 | { 147 | "name": "softDrink", 148 | "producerName": "Boneyard", 149 | "beverageName": "Lemon Ginger CBD Elixir Soda", 150 | "beverageColor": "#FAE725", 151 | "beverageStyle": "25mg of CBD per 12oz CBD Soda", 152 | "producerLocation": "Bend, OR", 153 | "abv": null, 154 | "ibu": null, 155 | "logo": "https://s3.amazonaws.com/digitalpourbeveragelogos/5b6a045735272603b840876f.png", 156 | "level": 81.08108108108108 157 | }, 158 | { 159 | "name": "beer", 160 | "producerName": "Lost Coast", 161 | "beverageName": "Tangerine Wheat", 162 | "beverageColor": "#EDAD27", 163 | "beverageStyle": "Wheat Ale", 164 | "producerLocation": "Eureka, CA", 165 | "abv": 5, 166 | "ibu": 15, 167 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/501233839294c3198c3fd2ea.png", 168 | "level": 81.08108108108108 169 | }, 170 | { 171 | "name": "beer", 172 | "producerName": "Boneyard", 173 | "beverageName": "Diablo Rojo", 174 | "beverageColor": "#A83E08", 175 | "beverageStyle": "Red Ale", 176 | "producerLocation": "Bend, OR", 177 | "abv": 5, 178 | "ibu": 30, 179 | "logo": "https://s3.amazonaws.com/digitalpourbeveragelogos/501234a89294c3198c3fd6e2.png", 180 | "level": 29.72972972972973 181 | }, 182 | { 183 | "name": "beer", 184 | "producerName": "Chuckanut", 185 | "beverageName": "Kölsch", 186 | "beverageColor": "#F0DD26", 187 | "beverageStyle": "Kölsch", 188 | "producerLocation": "Bellingham, WA", 189 | "abv": 4, 190 | "ibu": 20, 191 | "logo": "https://s3.amazonaws.com/digitalpourbeveragelogos/53366ef8fb890c0f78636f86.png", 192 | "level": 37.83783783783784 193 | }, 194 | { 195 | "name": "beer", 196 | "producerName": "North Coast", 197 | "beverageName": "Old Stock - Cellar Reserve 2017", 198 | "beverageColor": "#7A3911", 199 | "beverageStyle": "Barrel Aged Vintage Old Ale - Barrel Aged (Bourbon)", 200 | "producerLocation": "Fort Bragg, CA", 201 | "abv": 13, 202 | "ibu": null, 203 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/501233799294c3198c3fd288.png", 204 | "level": 83.78378378378379 205 | }, 206 | { 207 | "name": "beer", 208 | "producerName": "Schofferhofer", 209 | "beverageName": "Grapefruit Hefeweizen", 210 | "beverageColor": "#F59033", 211 | "beverageStyle": "Hefeweizen w/ Grapefruit Juice", 212 | "producerLocation": "Frankfurt, Germany", 213 | "abv": 2, 214 | "ibu": null, 215 | "logo": "https://s3.amazonaws.com/digitalpourbeveragelogos/58daf0ca5e002c14e82e1dc4.png", 216 | "level": 70.27027027027027 217 | }, 218 | { 219 | "name": "beer", 220 | "producerName": "Mac & Jack's", 221 | "beverageName": "African Amber", 222 | "beverageColor": "#BF621B", 223 | "beverageStyle": "Amber Ale", 224 | "producerLocation": "Redmond, WA", 225 | "abv": 5, 226 | "ibu": 30, 227 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/515884f2fb890c0fc4ded1a8.png", 228 | "level": 64.86486486486487 229 | }, 230 | { 231 | "name": "beer", 232 | "producerName": "Sunriver", 233 | "beverageName": "Fuzztail Hefeweizen", 234 | "beverageColor": "#EFEF07", 235 | "beverageStyle": "American Hefeweizen", 236 | "producerLocation": "Sunriver, OR", 237 | "abv": 5, 238 | "ibu": 20, 239 | "logo": "https://s3.amazonaws.com/digitalpourbeveragelogos/555fa8fc5e002c0640d43749.jpeg", 240 | "level": 16.216216216216218 241 | }, 242 | { 243 | "name": "cider", 244 | "producerName": "Portland Cider Co", 245 | "beverageName": "Peach Berry", 246 | "beverageColor": "#FF507A", 247 | "beverageStyle": "Cider", 248 | "producerLocation": "Clackamas, OR", 249 | "abv": 5, 250 | "ibu": null, 251 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/59b995ab5e002c0af0c7b4c1.PNG", 252 | "level": 37.83783783783784 253 | }, 254 | { 255 | "name": "cider", 256 | "producerName": "Bauman's", 257 | "beverageName": "Loganberry", 258 | "beverageColor": "#8A084D", 259 | "beverageStyle": "Berry Cider", 260 | "producerLocation": "Gervais, OR", 261 | "abv": 6, 262 | "ibu": null, 263 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/56d0dc365e002c0d50421cd3.png", 264 | "level": 2.7027027027027026 265 | }, 266 | { 267 | "name": "cider", 268 | "producerName": "Portland", 269 | "beverageName": "Pineapple Rosé", 270 | "beverageColor": "#F29494", 271 | "beverageStyle": "Cider w/ Pineapple & Blueberries", 272 | "producerLocation": "Clackamas, OR", 273 | "abv": 5, 274 | "ibu": null, 275 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/59b995ab5e002c0af0c7b4c1.PNG", 276 | "level": 81.08108108108108 277 | }, 278 | { 279 | "name": "cider", 280 | "producerName": "Ciderboys", 281 | "beverageName": "Strawberry Magic", 282 | "beverageColor": "#F37A7D", 283 | "beverageStyle": "Strawberry Cider", 284 | "producerLocation": "Stevens Point, WI", 285 | "abv": 5, 286 | "ibu": null, 287 | "logo": "https://s3.amazonaws.com/digitalpourbeveragelogos/55eaefd65e002c08b4b4845f.png", 288 | "level": 83.78378378378379 289 | }, 290 | { 291 | "name": "beer", 292 | "producerName": "Sunriver", 293 | "beverageName": "Cocoa Cow", 294 | "beverageColor": "#211208", 295 | "beverageStyle": "Milk Stout w/ Cocoa nibs *Contains Lactose", 296 | "producerLocation": "Sunriver, OR", 297 | "abv": 7, 298 | "ibu": 28, 299 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/5421c41dfb890e0808aeaef5.png", 300 | "level": 16.216216216216218 301 | }, 302 | { 303 | "name": "beer", 304 | "producerName": "Ecliptic", 305 | "beverageName": "Capella", 306 | "beverageColor": "#211102", 307 | "beverageStyle": "Porter", 308 | "producerLocation": "Portland, OR", 309 | "abv": 5, 310 | "ibu": 39, 311 | "logo": "https://s3.amazonaws.com/digitalpourbeveragelogos/57609f585e002c0b5417c1aa.png", 312 | "level": 24.324324324324326 313 | }, 314 | { 315 | "name": "beer", 316 | "producerName": "Crux", 317 | "beverageName": "Stout (Nitro)", 318 | "beverageColor": "#190E03", 319 | "beverageStyle": "American Stout", 320 | "producerLocation": "Bend, OR", 321 | "abv": 7, 322 | "ibu": 60, 323 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/50b6719bfb890c045804f672.png", 324 | "level": 2.7027027027027026 325 | }, 326 | { 327 | "name": "beer", 328 | "producerName": "Lindemans", 329 | "beverageName": "Framboise", 330 | "beverageColor": "#EB1923", 331 | "beverageStyle": "Raspberry Lambic", 332 | "producerLocation": "Vlezenbeek, Belgium", 333 | "abv": 2, 334 | "ibu": 12, 335 | "logo": "https://s3.amazonaws.com/digitalpourbeveragelogos/5511adabb3b6f60ea02431d8.png", 336 | "level": 100 337 | }, 338 | { 339 | "name": "wine", 340 | "producerName": "Volcano", 341 | "beverageName": "Peach Sangria", 342 | "beverageColor": "#F2937C", 343 | "beverageStyle": "", 344 | "producerLocation": "", 345 | "abv": 6, 346 | "ibu": null, 347 | "logo": "https://s3.amazonaws.com/digitalpourbeveragelogos/586d55605e002c0a60819fa1.png", 348 | "level": 94.5945945945946 349 | }, 350 | { 351 | "name": "wine", 352 | "producerName": "Wine By Joe", 353 | "beverageName": "Rose'", 354 | "beverageColor": "#F77272", 355 | "beverageStyle": "", 356 | "producerLocation": "USA", 357 | "abv": 13, 358 | "ibu": null, 359 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/586d64075e002c0a6081a345.png", 360 | "level": 89.1891891891892 361 | }, 362 | { 363 | "name": "wine", 364 | "producerName": "Maryhill", 365 | "beverageName": "Pinot Gris", 366 | "beverageColor": "#FEF46E", 367 | "beverageStyle": "", 368 | "producerLocation": "USA", 369 | "abv": 13, 370 | "ibu": null, 371 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/5a2b02515e002d0f80c6e3af.png", 372 | "level": 72.97297297297297 373 | }, 374 | { 375 | "name": "wine", 376 | "producerName": "Lunetta", 377 | "beverageName": "Prosecco", 378 | "beverageColor": "#FFFE04", 379 | "beverageStyle": "", 380 | "producerLocation": "Italy", 381 | "abv": 12, 382 | "ibu": null, 383 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/586db7605e002c08c4269583.png", 384 | "level": 2.7027027027027026 385 | }, 386 | { 387 | "name": "wine", 388 | "producerName": "Coopers Hall", 389 | "beverageName": "Cascade Red Wine Blend", 390 | "beverageColor": "#6B0536", 391 | "beverageStyle": "", 392 | "producerLocation": "USA", 393 | "abv": 12, 394 | "ibu": null, 395 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/586d671a5e002c091017521e.png", 396 | "level": 21.62162162162162 397 | }, 398 | { 399 | "name": "softDrink", 400 | "producerName": "Ablis", 401 | "beverageName": "Strawberry Mojito", 402 | "beverageColor": "#F2A586", 403 | "beverageStyle": "CBD Soda", 404 | "producerLocation": "Bend, OR", 405 | "abv": null, 406 | "ibu": null, 407 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/596673705e002c02acd05d25.png", 408 | "level": 40.54054054054054 409 | }, 410 | { 411 | "name": "kombucha", 412 | "producerName": "Soma", 413 | "beverageName": "Strawberry CBD Kombucha", 414 | "beverageColor": "#C1C219", 415 | "beverageStyle": "Kombucha 10 Mg per 16 oz", 416 | "producerLocation": "Portland, Or", 417 | "abv": 0, 418 | "ibu": null, 419 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/5567872d5e002c0e60ae5d83.png", 420 | "level": 97.2972972972973 421 | }, 422 | { 423 | "name": "kombucha", 424 | "producerName": "Humm", 425 | "beverageName": "Coconut Lime", 426 | "beverageColor": "#C1C219", 427 | "beverageStyle": "Kombucha", 428 | "producerLocation": "Bend, OR", 429 | "abv": 0, 430 | "ibu": null, 431 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/528ee297df752b2e643fe5ff.png", 432 | "level": 100 433 | }, 434 | { 435 | "name": "kombucha", 436 | "producerName": "Happy Mountain", 437 | "beverageName": "Huckleberry", 438 | "beverageColor": "#BFF246", 439 | "beverageStyle": "Kombucha", 440 | "producerLocation": "Portland, OR", 441 | "abv": null, 442 | "ibu": null, 443 | "logo": "https://s3.amazonaws.com/digitalpourproducerlogos/535dc840fb890c0924b1da3f.png", 444 | "level": 13.513513513513514 445 | } 446 | ] 447 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jherr/ts-hooks/28ab09e250ca97e2693a49838be6e7008b344e71/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jherr/ts-hooks/28ab09e250ca97e2693a49838be6e7008b344e71/public/logo512.png -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/App.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render, screen } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | render(); 7 | const linkElement = screen.getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /src/App.tsx: -------------------------------------------------------------------------------- 1 | import UseStateComponent from "./UseStateComponent"; 2 | import UseEffectComponent from "./UseEffectComponent"; 3 | import UseContextComponent from "./UseContextComponent"; 4 | import UseReducerComponent from "./UseReducerComponent"; 5 | import UseRefComponent from "./UseRefComponent"; 6 | import CustomHookComponent from "./CustomHookComponent"; 7 | 8 | import EvenMoreReactComponent from "./EvenMoreReactComponent"; 9 | 10 | function App() { 11 | return ( 12 |
13 |

Even more React component TS stuff

14 | 15 |

Custom Hook

16 | 17 |

useRef

18 | 19 |

useReducer

20 | 21 |

useContext

22 | 23 |

useEffect

24 | 25 |

useState

26 | 27 |
28 | ); 29 | } 30 | 31 | export default App; 32 | -------------------------------------------------------------------------------- /src/CustomHookComponent.tsx: -------------------------------------------------------------------------------- 1 | import { useState, useEffect, useMemo } from "react"; 2 | 3 | export interface Beverage { 4 | name: string; 5 | producerName: string; 6 | beverageName: string; 7 | beverageColor: string; 8 | beverageStyle: string; 9 | producerLocation: string; 10 | abv: number; 11 | ibu: number; 12 | logo: string; 13 | level: number; 14 | } 15 | 16 | function useFetchData( 17 | url: string 18 | ): { 19 | data: Payload | null; 20 | done: boolean; 21 | } { 22 | const [data, dataSet] = useState(null); 23 | const [done, doneSet] = useState(false); 24 | 25 | useEffect(() => { 26 | fetch(url) 27 | .then((resp) => resp.json()) 28 | .then((d: Payload) => { 29 | dataSet(d); 30 | doneSet(true); 31 | }); 32 | }, [url]); 33 | 34 | return { 35 | data, 36 | done, 37 | }; 38 | } 39 | 40 | function CustomHookComponent() { 41 | const { data } = useFetchData("/hv-taplist.json"); 42 | const portlandTaps = useMemo( 43 | () => 44 | (data || []).filter((bev) => bev.producerLocation.includes("Portland")), 45 | [data] 46 | ); 47 | 48 | return ( 49 |
50 | {portlandTaps.length && ( 51 | Beverage logo 52 | )} 53 |
54 | ); 55 | } 56 | 57 | export default CustomHookComponent; 58 | -------------------------------------------------------------------------------- /src/EvenMoreReactComponent.tsx: -------------------------------------------------------------------------------- 1 | import { ReactElement, ReactNode } from "react"; 2 | 3 | export interface HeadingProps { 4 | title: string; 5 | } 6 | export const Heading = ({ title }: HeadingProps) => { 7 | return

{title}

; 8 | }; 9 | 10 | export const List: ({ 11 | items, 12 | render, 13 | }: { 14 | items: ListItem[]; 15 | render: (item: ListItem) => ReactNode; 16 | }) => ReactElement = ({ items, render }) => { 17 | return ( 18 |
    19 | {items.map((item, index) => ( 20 |
  • {render(item)}
  • 21 | ))} 22 |
23 | ); 24 | }; 25 | 26 | function TestComponent() { 27 | return ( 28 |
29 | 30 | {str}} /> 31 |
32 | ); 33 | } 34 | 35 | export default TestComponent; 36 | -------------------------------------------------------------------------------- /src/UseContextComponent.tsx: -------------------------------------------------------------------------------- 1 | import { useState, useContext } from "react"; 2 | 3 | import UserContext, { UserState } from "./store"; 4 | 5 | function ConsumerComponent() { 6 | const user = useContext(UserContext); 7 | 8 | return ( 9 |
10 |
First: {user.first}
11 |
Last: {user.last}
12 |
13 | ); 14 | } 15 | 16 | function UseContextComponent() { 17 | const [user, userSet] = useState({ 18 | first: "Jane", 19 | last: "Smith", 20 | }); 21 | 22 | return ( 23 | 24 | 25 | 35 | 36 | ); 37 | } 38 | 39 | export default UseContextComponent; 40 | -------------------------------------------------------------------------------- /src/UseEffectComponent.tsx: -------------------------------------------------------------------------------- 1 | import { useState, useEffect } from "react"; 2 | 3 | function UseEffectComponent() { 4 | const [val, valSet] = useState(1); 5 | 6 | useEffect(() => { 7 | const timer = window.setInterval(() => { 8 | valSet((v) => v + 1); 9 | }, 1000); 10 | return () => window.clearInterval(timer); 11 | }, []); 12 | 13 | return
{val}
; 14 | } 15 | 16 | export default UseEffectComponent; 17 | -------------------------------------------------------------------------------- /src/UseReducerComponent.tsx: -------------------------------------------------------------------------------- 1 | import { useReducer } from "react"; 2 | 3 | const initialState = { 4 | counter: 100, 5 | }; 6 | 7 | type ACTIONTYPES = 8 | | { type: "increment"; payload: number } 9 | | { type: "decrement"; payload: number }; 10 | 11 | function counterReducer(state: typeof initialState, action: ACTIONTYPES) { 12 | switch (action.type) { 13 | case "increment": 14 | return { 15 | ...state, 16 | counter: state.counter + action.payload, 17 | }; 18 | case "decrement": 19 | return { 20 | ...state, 21 | counter: state.counter - action.payload, 22 | }; 23 | default: 24 | throw new Error("Bad action"); 25 | } 26 | } 27 | 28 | function UseReducerComponent() { 29 | const [state, dispatch] = useReducer(counterReducer, initialState); 30 | 31 | return ( 32 |
33 |
{state.counter}
34 |
35 | {" "} 45 | | 46 | 56 |
57 |
58 | ); 59 | } 60 | 61 | export default UseReducerComponent; 62 | -------------------------------------------------------------------------------- /src/UseRefComponent.tsx: -------------------------------------------------------------------------------- 1 | import { useRef } from "react"; 2 | 3 | function UseRefComponent() { 4 | const inputRef = useRef(null); 5 | 6 | return ( 7 |
8 | ; 9 | 16 |
17 | ); 18 | } 19 | 20 | export default UseRefComponent; 21 | -------------------------------------------------------------------------------- /src/UseStateComponent.tsx: -------------------------------------------------------------------------------- 1 | import { useState } from "react"; 2 | 3 | function UseStateComponent() { 4 | const [arr, arrSet] = useState([]); 5 | const [name, nameSet] = useState(null); 6 | 7 | return ( 8 |
9 |
10 | 13 | {JSON.stringify(arr)} 14 |
15 |
16 | 17 | {JSON.stringify(name)} 18 |
19 |
20 | ); 21 | } 22 | 23 | export default UseStateComponent; 24 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: auto; 3 | max-width: 800px; 4 | padding: 1rem; 5 | font-size: x-large; 6 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 7 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 8 | sans-serif; 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | } 12 | 13 | code { 14 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 15 | monospace; 16 | } 17 | -------------------------------------------------------------------------------- /src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /src/store.ts: -------------------------------------------------------------------------------- 1 | import { createContext } from "react"; 2 | 3 | const initialState = { 4 | first: "Jack", 5 | last: "Herrington", 6 | }; 7 | 8 | export type UserState = typeof initialState; 9 | 10 | const context = createContext(initialState); 11 | 12 | export default context; 13 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | --------------------------------------------------------------------------------