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
| // This is what eslint wants | |
| type Foo = Omit< | |
| Bar, 'baz' | |
| >; | |
| type Foo = Omit< | |
| Bar, 'baz' | |
| >; |
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
| export default function ContactForm() { | |
| const [sendContactForm] = useSendContactFormMutation(); | |
| const handleSubmit = async () => { | |
| const formData = {}; | |
| // If I need the error for this component | |
| try { | |
| await sendContactForm(formData).unwrap(); | |
| } catch (error) { |
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
| <button data-delete-id="1">One</button> | |
| <button data-delete-id="2">Two</button> | |
| <button data-delete-id="3">Three</button> |
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
| @keyframes tooltipFadeIn { | |
| from { | |
| opacity: 0; | |
| } | |
| to { | |
| opacity: 1; | |
| } | |
| } | |
| body { | |
| padding: 16px; |
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 queue(arr, item) { | |
| return [...arr.length >= 3 ? arr.slice(1) : arr, item]; | |
| } | |
| const a = queue(['one'], 'two'); | |
| const b = queue(a, 'three'); | |
| const c = queue(b, 'four'); | |
| const d = queue(c, 'five'); | |
| console.log(d); |
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
| <html lang="en"> | |
| <head> | |
| <script src="./script.js" defer></script> | |
| </head> | |
| <body> | |
| <div data-id="parent"> | |
| <button type="button">Button 1</button> | |
| <button type="button">Button 2</button> | |
| <button type="button">Button 3</button> |
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 ChildComponent({ callback }) {} | |
| const MemoizedChildComponent = React.memo(ChildComponent); | |
| function ParentComponent() { | |
| const onClick = useCallback(() => { | |
| console.log('Foo'); | |
| }, []); | |
| return <MemoizedChildComponent callback={onClick} />; | |
| } |
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
| const o = [ | |
| { name: 'Bobby', group: 1 }, | |
| { name: 'Jimmy', group: 2 }, | |
| { name: 'Tommy', group: 1 }, | |
| ]; | |
| function groupBy(arr, key = 'group') { | |
| const map = arr.reduce((acc, curr) => ({ | |
| ...acc, | |
| [curr[key]]: [...(acc[curr[key]] || []), curr], |
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 List({ items }) { | |
| if (!items?.length) { | |
| return <p>Nothing to see here...</p>; | |
| } | |
| return ( | |
| <ul> | |
| {items.map((item) => ( | |
| <li key={item.id}> | |
| {!!item.image && <img src={item.image} alt={item.imageAlt} />} |
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
| const preferredStores=[{"PreferredStoreName":"Stater Bros","PreferredStoreID":3},{"PreferredStoreName":"Ralph's","PreferredStoreID":7}]; | |
| const preferredStoreItems=[{"GroceryItemID":3,"Name":"Test","PreferredStoreID":3,"Notes":"Test","CreatedOn":"Apr 30 2021 10:43PM"},{"GroceryItemID":2,"Name":"Baguette","PreferredStoreID":7,"Notes":"","CreatedOn":"Apr 30 2021 10:43PM"},{"GroceryItemID":1,"Name":"Saltines","PreferredStoreID":3,"Notes":"","CreatedOn":"Apr 30 2021 6:26AM"}] | |
| const uniquePreferredStores = [...new Set(preferredStoreItems.map(({ PreferredStoreID }) => PreferredStoreID))]; | |
| const z = uniquePreferredStores.reduce((acc, uId) => ({ | |
| ...acc, | |
| [uId]: acc[uId] || preferredStores.find((store) => store.PreferredStoreID === uId)?.PreferredStoreName, | |
| }), {}); |