Skip to content

Instantly share code, notes, and snippets.

View lalalam123's full-sized avatar

Chan Sik Lam lalalam123

View GitHub Profile
@lalalam123
lalalam123 / CustomArrayHooks.ts
Last active September 1, 2023 18:03
Custom Hooks for arrays
import { useState } from 'react';
type ArrayStateActions<T> = {
add: (item: T) => void;
remove: (item: T) => void;
clear: () => void;
};
const useArrayState = <T>(
inistialItems: T[],