Skip to content

Instantly share code, notes, and snippets.

@KATT
KATT / favourite-ts-tricks.md
Last active July 26, 2023 06:16
🧙‍♂️ Favourite non-obvious TS tricks

Record<string, x | undefined>

Represent maps

// rather than 
const map: {[ key: string ]: string} = {
  foo: 'bar',
}
@KATT
KATT / .env.local.js
Last active May 17, 2020 12:12
VSCode for codegen
// gitignore this file
module.exports = {
HASURA_URL: 'https://myapp.herokuapp.com/v1/graphql',
HASURA_ADMIN_SECRET: 'xxx',
};
@joshuacerbito
joshuacerbito / useScroll.js
Last active January 8, 2024 13:44
Custom React hook for listening to scroll events
/**
* useScroll React custom hook
* Usage:
* const { scrollX, scrollY, scrollDirection } = useScroll();
*/
import { useState, useEffect } from "react";
export function useScroll() {
const [lastScrollTop, setLastScrollTop] = useState(0);