mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-06-09 09:04:20 +02:00
add useMemo to useAction
This commit is contained in:
parent
5c841bcbd9
commit
43b68d427a
@ -1,11 +1,16 @@
|
|||||||
import { useDispatch } from "react-redux"
|
import { useDispatch } from "react-redux"
|
||||||
|
import { useMemo } from "react"
|
||||||
|
|
||||||
const useAction = (action: (...args: any[]) => any): any => {
|
const useAction = (action: (...args: any[]) => any): any => {
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
|
|
||||||
return (...args: any[]) => {
|
return useMemo(
|
||||||
|
() =>
|
||||||
|
(...args: any[]) => {
|
||||||
dispatch(action(...args))
|
dispatch(action(...args))
|
||||||
}
|
},
|
||||||
|
[dispatch, action]
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default useAction
|
export default useAction
|
||||||
|
Loading…
x
Reference in New Issue
Block a user