Skip to content

Instantly share code, notes, and snippets.

View leandiazz's full-sized avatar
:electron:
Handcrafting each line of code

Leandro leandiazz

:electron:
Handcrafting each line of code
View GitHub Profile
@acorn1010
acorn1010 / createGlobalStore.ts
Last active January 31, 2025 01:01
Easier Zustand store
import {SetStateAction, useCallback} from 'react';
import {create} from "zustand";
export type EqualityFn<T> = (left: T | null | undefined, right: T | null | undefined) => boolean;
export type StoreType<State> = {
use<K extends keyof State>(
key: K,
defaultValue?: State[K],
equalityFn?: EqualityFn<State[K]>,