summaryrefslogtreecommitdiffhomepage
path: root/gui/src/renderer/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gui/src/renderer/lib')
-rw-r--r--gui/src/renderer/lib/actionsHook.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/gui/src/renderer/lib/actionsHook.ts b/gui/src/renderer/lib/actionsHook.ts
new file mode 100644
index 0000000000..2597aee422
--- /dev/null
+++ b/gui/src/renderer/lib/actionsHook.ts
@@ -0,0 +1,9 @@
+import { useMemo } from 'react';
+import { useDispatch } from 'react-redux';
+import { ActionCreatorsMapObject, bindActionCreators } from 'redux';
+
+export default function useActions<A, M extends ActionCreatorsMapObject<A>>(actionCreator: M) {
+ const dispatch = useDispatch();
+ const actions = useMemo(() => bindActionCreators(actionCreator, dispatch), [dispatch]);
+ return actions;
+}