Here is a quick guide for getting set up with a basic react app with eslint and prettier
- First run
npx create-react-app app-name
cd app-name| function parseEmojis(str) { | |
| return str.match(/(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?)*/); | |
| } |
git checkout -b NEW_BRANCHgit remote add upstream ORIGINAL_REPO_URL| { | |
| "name": "eslint-prettier-demo", | |
| "version": "0.1.0", | |
| "private": true, | |
| "dependencies": { | |
| "react": "^16.9.0", | |
| "react-dom": "^16.9.0", | |
| "react-scripts": "3.1.1" | |
| }, | |
| "scripts": { |
| // https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html | |
| function getMinContrastColor(rgb, isLargeFont) { | |
| const minContrastRatio = isLargeFont ? 3.0 : 4.5; | |
| let contrastIsDark = isContrastDark(rgb); | |
| let i = 0.01; | |
| let contrastRgb = []; | |
| let contrastRatio = 0; | |
| while (contrastRatio < minContrastRatio && i < 1) { | |
| contrastRgb = calculateGradient(rgb, contrastIsDark, i); |
Note: this feature is available with react-scripts@1.0.0 and higher.
.env: Default..env.local: Local overrides. This file is loaded for all environments except test..env.development, .env.test, .env.production: Environment-specific settings..env.development.local, .env.test.local, .env.production.local: Local overrides of environment-specific settings.| const getDadJoke = async () => { | |
| const dadJoke = await fetch("https://icanhazdadjoke.com/", { | |
| headers: { | |
| Accept: "application/json" | |
| } | |
| }); | |
| const dadJokeJSON = await dadJoke.json(); | |
| if (dadJokeJSON.status === 200) { | |
| return dadJokeJSON.joke; | |
| } else { |
| // ---------------------------------------------------------------------- // | |
| // https://developers.google.com/maps/documentation/geocoding/intro#Types // | |
| // ---------------------------------------------------------------------- // | |
| // returns: | |
| // { | |
| // address_1 | |
| // address_2 | |
| // city |
| $gap: 1rem; | |
| .grid { | |
| display: flex; | |
| margin: 0 calc(#{$gap} / -2) -$gap calc(#{$gap} / -2); | |
| flex-wrap: wrap; | |
| } | |
| .item { | |
| flex: 0 0 auto; |
| .container { | |
| position: relative; | |
| } | |
| .object: { | |
| position: absolute; | |
| top: 50%; // moves the element 50% from the top of the container | |
| left: 50%; // moves the element 50% from the left of the container | |
| transform: translate(-50%, -50%); // move the element back up and to the left half of its total size | |
| } |