Skip to content

Instantly share code, notes, and snippets.

View timothymiller's full-sized avatar
🎄

Timothy Miller timothymiller

🎄
View GitHub Profile
@timothymiller
timothymiller / useQueryState.ts
Created September 12, 2022 14:20 — forked from SebastianHGonzalez/useQueryState.ts
useQueryState - query string synchronized use state hook for next.js
import { useState, useEffect } from "react";
import { useRouter } from "next/router";
type IParam = string;
type IValue = string | string[] | number | number[] | null | undefined;
type IState = { [k: string]: IValue };
type IQuery = IState;
type IRoute = string;
function isEmpty(value: IValue): boolean {