mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-25 06:24:19 +00:00
🐛 Fix hooks dependencies
This commit is contained in:
parent
344544da52
commit
c81f50e3df
3 changed files with 17 additions and 7 deletions
|
@ -10,10 +10,10 @@ export default function useArrayState(def) {
|
|||
oldArray => [...oldArray, newSingle]
|
||||
)
|
||||
},
|
||||
[value, setValue]
|
||||
[]
|
||||
)
|
||||
|
||||
const removeValue = useCallback(
|
||||
const spliceValue = useCallback(
|
||||
position => {
|
||||
setValue(
|
||||
oldArray => {
|
||||
|
@ -22,8 +22,18 @@ export default function useArrayState(def) {
|
|||
return oldArray
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
[]
|
||||
)
|
||||
|
||||
return {value, setValue, appendValue, removeValue}
|
||||
const removeValue = useCallback(
|
||||
remValue => {
|
||||
setValue(
|
||||
oldArray => oldArray.filter(item => item !== remValue)
|
||||
)
|
||||
},
|
||||
[]
|
||||
)
|
||||
|
||||
return {value, setValue, appendValue, spliceValue, removeValue}
|
||||
}
|
|
@ -35,7 +35,7 @@ export default function useData(fetchData, method, path, body, init) {
|
|||
setLoading(false)
|
||||
}
|
||||
},
|
||||
[fetchData, method, path, body, init, setData, setError, setLoading]
|
||||
[fetchData, method, path, body, init]
|
||||
)
|
||||
|
||||
/**
|
||||
|
@ -51,7 +51,7 @@ export default function useData(fetchData, method, path, body, init) {
|
|||
|
||||
await load()
|
||||
},
|
||||
[load, setData, setError]
|
||||
[load]
|
||||
)
|
||||
|
||||
useEffect(
|
||||
|
|
|
@ -54,7 +54,7 @@ export default function useLocalStorageState(key, def) {
|
|||
setValue(value)
|
||||
save(value)
|
||||
},
|
||||
[setValue, save]
|
||||
[save]
|
||||
)
|
||||
|
||||
return [value, setAndSave]
|
||||
|
|
Loading…
Reference in a new issue