Snippets
Inspired by Josh W. Comeau's snippets, this is a collection of code snippets I've made over the years that you can look at for inspiration or copy/paste at will.
Name | Description | Category |
---|---|---|
clamp() | Description: A function that "clamps" a number between a minimum and maximum value | Category: JavaScript |
compose() & pipe() | Description: Functions for composing other functions | Category: JavaScript |
indexByKey() | Description: A function to turn an array of objects into an object, indexed by the chosen key | Category: JavaScript |
inflect() | Description: Function used to choose the correct form of a word, singular or plural | Category: JavaScript |
Margin | Description: A component for easily applying margins with component composition | Category: React Component |
partition() | Description: Split an array with a predicate filter | Category: JavaScript |
randomRGB() | Description: Function to generate random rgb() strings | Category: JavaScript |
React Native Layout components | Description: Copy/pasteable layout components for React Native | Category: React Native |
ShiftBy | Description: A component for compositionally adjusting an element to pixel perfect alignment | Category: Astro |
toArray() | Description: A function for normalizing a value to an array | Category: JavaScript |
useAsyncSafeState() | Description: Hook for async state that automatically prevents memory leaks | Category: React Hooks |
useBool() | Description: A basic React Hook for managing binary states | Category: React Hooks |
useForceUpdate() | Description: An imperative way to force a component to update with Hooks | Category: React Hooks |
useLocalStorage() |
Description:
Hook for persisting state to localStorage | Category: React Hooks |
usePrevious() | Description: Hook for storing and getting a previous value | Category: React Hooks |