mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-06-08 08:34: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 { useMemo } from "react"
|
||||
|
||||
const useAction = (action: (...args: any[]) => any): any => {
|
||||
const dispatch = useDispatch()
|
||||
|
||||
return (...args: any[]) => {
|
||||
dispatch(action(...args))
|
||||
}
|
||||
return useMemo(
|
||||
() =>
|
||||
(...args: any[]) => {
|
||||
dispatch(action(...args))
|
||||
},
|
||||
[dispatch, action]
|
||||
)
|
||||
}
|
||||
|
||||
export default useAction
|
||||
|
Loading…
x
Reference in New Issue
Block a user