mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-06-11 01:54:21 +02:00
17 lines
359 B
TypeScript
17 lines
359 B
TypeScript
import { useDispatch } from "react-redux"
|
|
import { useMemo } from "react"
|
|
|
|
const useAction = (action: (...args: any[]) => any): any => {
|
|
const dispatch = useDispatch()
|
|
|
|
return useMemo(
|
|
() =>
|
|
(...args: any[]) => {
|
|
dispatch(action(...args))
|
|
},
|
|
[dispatch, action]
|
|
)
|
|
}
|
|
|
|
export default useAction
|