Add pomodoro timer

This commit is contained in:
Sakura Knoll
2022-09-12 07:49:42 +09:00 Unverified
parent 3be94aee50
commit 502d4d8976
35 changed files with 1642 additions and 32 deletions
+30
View File
@@ -0,0 +1,30 @@
import {
Dispatch,
MutableRefObject,
SetStateAction,
useEffect,
useRef,
useState,
} from 'react'
export function useRefState<S>(
initialState: S | (() => S)
): [S, Dispatch<SetStateAction<S>>, MutableRefObject<S>] {
const [state, setState] = useState<S>(initialState)
const stateRef = useRef(state)
useEffect(() => {
stateRef.current = state
}, [state])
return [state, setState, stateRef]
}
export function useTimer() {}
export function useValueRef<V>(value: V) {
const ref = useRef(value)
useEffect(() => {
ref.current = value
}, [value])
return ref
}