Skip to content

Instantly share code, notes, and snippets.

View emekaorji's full-sized avatar
👣
in a waverider

Emeka Orji emekaorji

👣
in a waverider
View GitHub Profile
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
@emekaorji
emekaorji / useElectronStore.js
Last active February 8, 2024 23:03
A react hook to establish a sync with the electron store with real-time updates.
import { Dispatch, SetStateAction, useEffect, useRef, useState } from 'react';
function useStoreState<T>(
_key: string,
_initialValue: T | (() => T)
): [T, Dispatch<SetStateAction<T>>];
function useStoreState<T = undefined>(
_key: string
): [T | undefined, Dispatch<SetStateAction<T | undefined>>];