1
0
mirror of https://github.com/uetchy/namae.git synced 2025-08-20 18:08:11 +09:00

fix(web): rename hooks file

This commit is contained in:
2019-08-14 20:00:31 +09:00
parent fc034bc2bb
commit e0a03406a5
2 changed files with 1 additions and 1 deletions

18
web/src/util/hooks.js Normal file
View File

@@ -0,0 +1,18 @@
import { useState, useEffect } from 'react'
export function useDeferredState(duration = 1000, initialValue = undefined) {
const [response, setResponse] = useState(initialValue)
const [innerValue, setInnerValue] = useState(initialValue)
useEffect(() => {
const fn = setTimeout(() => {
setResponse(innerValue)
}, duration)
return () => {
clearTimeout(fn)
}
}, [duration, innerValue])
return [response, setInnerValue]
}