Skip to content

Instantly share code, notes, and snippets.

View gleydson's full-sized avatar
🏠
Working at home

gleydson gleydson

🏠
Working at home
View GitHub Profile
@t3dotgg
t3dotgg / try-catch.ts
Last active October 30, 2025 20:51
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@cassidoo
cassidoo / mergerefs.jsx
Created January 10, 2023 22:57
Merge refs in React so a component can have more than one ref
export function mergeRefs(refs) {
return (value) => {
refs.forEach((ref) => {
if (typeof ref === "function") {
ref(value);
} else if (ref != null) {
ref.current = value;
}
});
};
@mrousavy
mrousavy / MEMOIZE.md
Last active October 20, 2025 02:24
Memoize!!! 💾 - a react (native) performance guide
In computing, memoization or memoisation
is an optimization technique used primarily
to speed up computer programs by storing
the results of expensive function calls and  
returning the cached result when the same
inputs occur again.                                         
                                                     — wikipedia