This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onSubmit(values) { | |
return new Promise((resolve) => { | |
setTimeout(() => { | |
alert(JSON.stringify(values, null, 2)); | |
resolve(); | |
}, 3000); | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create union out of properties in an interface who'se value type match then given value types (can be given a union of types to match) #codesnippet | |
// Stack Overflow explanation https://stackoverflow.com/questions/54520676/in-typescript-how-to-get-the-keys-of-an-object-type-whose-values-are-of-a-given/66144780 | |
export type KeysUnion<T, V> = { [K in keyof T]-?: T[K] extends V ? K : never }[keyof T]; | |
// Playground | |
interface Cool { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = | |
Pick<T, Exclude<keyof T, Keys>> | |
& { | |
[K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>> | |
}[Keys] | |
// ************************************************************ | |
interface MenuItem { | |
title: string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import faker from "faker"; | |
function createIterable(length: number) { | |
return Array.from(Array(length)); | |
} | |
function createFakeData<T>(datumCreator: any, length: number): T[] { | |
return createIterable(length).map(() => datumCreator()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import { render, screen } from '@testing-library/react'; | |
import userEvent from '@testing-library/user-event'; | |
import Login from '../../components/login'; | |
// https://github.com/marak/Faker.js/ | |
import faker from 'faker'; | |
function buildLoginFormFakeData(overrides) { | |
return { | |
username: faker.internet.userName(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ignore everything: | |
/* | |
# Except src: | |
!/src |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// e.g. 2 lines: | |
some-class { | |
display: -webkit-box; | |
-webkit-line-clamp: 2; | |
-webkit-box-orient: vertical; | |
overflow: hidden; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// return first, instead of wrapping the task itself in an if condition. | |
// this is better because it prevents the clearTimeout being run | |
function App() { | |
const [varA, setVarA] = useState(0); | |
useEffect(() => { | |
if (varA >= 5) return; | |
const timeout = setTimeout(() => setVarA(varA + 1), 1000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { COLORS, respondTo } from 'styles'; | |
const SideBarOffset = styled.div` | |
background-color: ${COLORS.MAIN};; | |
height: 100%; | |
width: ${(props) => props.offset + 'px'}; | |
flex-basis: auto; | |
${respondTo.tablet` | |
width: 0px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"search.exclude": { | |
"**/.gitignore": true, | |
"**/.netlify": true, | |
"**/*?config*?": true, | |
"**/build": true, | |
"**/node_modules": true, | |
"**/package-lock.json": true, | |
"**/package.json": true, | |
"**/README.md": true | |
} |
NewerOlder