similar to componentDidMount
import { useEffect } from 'react'
export default function Component() {
useEffect(() => {
// code to run when component mounts| async function getGithubGists() { | |
| const githubUsername = 'octocat' | |
| const gists = await fetch( | |
| `https://api.github.com/users/${githubUsername}/gists` | |
| ) | |
| const gistsJson = await gists.json() | |
| const snippets = [] |
| .selector { | |
| /* Positioning */ | |
| position: absolute; | |
| z-index: 10; | |
| top: 0; | |
| right: 0; | |
| /* Display & Box Model */ | |
| display: inline-block; | |
| overflow: hidden; |
| @media (min-width: 640px) { | |
| /* mobile (sm) */ | |
| } | |
| @media (min-width: 768px) { | |
| /* tablet (md) */ | |
| } | |
| @media (min-width: 1024px) { | |
| /* laptop (lg) */ |
Counter: https://100dayscss.com/?dayIndex=31
Gallery v1: https://100dayscss.com/?dayIndex=39
Gallery v2: https://100dayscss.com/?dayIndex=12
Notification: https://100dayscss.com/?dayIndex=25
| // https://github.com/softvar/js/blob/master/packages/util-array/src/index.ts#L97 | |
| function sortOnKey(arr, key, direction = 'asc' ) { | |
| if (!arr || !arr.length || !key) { | |
| return []; | |
| } | |
| const dir = direction === 'asc' ? 1 : -1 | |
| arr.sort((a, b) => { | |
| return b[key] > a[key] ? -1 : a[key] > b[key] ? dir : 0; | |
| }); |