Skip to content

Instantly share code, notes, and snippets.

View ynifamily3's full-sized avatar

Jongkeun Choi ynifamily3

View GitHub Profile
@ynifamily3
ynifamily3 / useRouterHelper.ts
Last active June 25, 2023 02:05
react-router-dom 헬퍼
import { useCallback, useMemo } from "react";
import { useLocation, useNavigate, useSearchParams } from "react-router-dom";
const _getAll = (urlSearchParams: URLSearchParams) => {
const ret: Record<string, string[]> = {};
for (const [k, v] of urlSearchParams.entries()) {
if (ret[k]) {
ret[k].push(v);
} else {
ret[k] = [v];
@ynifamily3
ynifamily3 / example.tsx
Last active November 13, 2023 01:40
전역 상태관리 예제 (useSyncExternalStore)
"use client";
import { todosStore } from "@/store/todoStore";
import { useSyncExternalStore } from "react";
export default function AAA() {
const todos = useSyncExternalStore(
todosStore.subscribe,
todosStore.getSnapshot
);