Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Jongkeun Choi ynifamily3

🏠
Working from home
View GitHub Profile
View useReactiveLocalItem.ts
import localItemContext, {
setLocalItemValue,
} from "#/context/localItemContext";
import { useReactiveVar } from "@apollo/client";
import { useCallback, useEffect } from "react";
type UseReactiveLocalItemReturnType = <V>(
key: string,
defaultValue?: V,
) => [V, (value: V | ((prevState: V) => V) | null) => void];
View dijkstra.cpp
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int solution(int N, vector<vector<int> > road, int K) {
int answer = 0;
int village[51][51];
int INF = 10000 * 50;
bool visited[51];
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
View useApi.ts
interface CombinedStatus<T> {
status: "IDLE" | "PENDING" | "SUCCESS" | "FAILURE";
data: T | null;
}
function useApi<ApiResultType extends object, Payload>(
repoFunc: (
payload: Payload
) => Promise<ApiResultType>
) {
const _repoFunc = useRef(repoFunc);
@ynifamily3
ynifamily3 / useLocalStorage.ts
Created Dec 5, 2020
로컬스토리지 저장 훅
View useLocalStorage.ts
import { useState } from "react";
export function useLocalStorage<T>(
key: string,
initialValue: T
): [T, (value: T | ((val: T) => T)) => void] {
const [storedValue, setStoredValue] = useState<T>(() => {
try {
const item = window.localStorage.getItem(key);
return item ? JSON.parse(item) : initialValue;