Add pomodoro timer
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user