Skip to content

Instantly share code, notes, and snippets.

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

Leandro leandiazz

😀
Handcrafting each line of code
View GitHub Profile
@acorn1010
acorn1010 / createGlobalStore.ts
Last active April 1, 2024 01:11
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]>,