From 714cecaba946bbee21946116d09dbbc87a70ba83 Mon Sep 17 00:00:00 2001 From: moklick Date: Mon, 25 May 2020 17:14:09 +0200 Subject: [PATCH] refactor(easy-peasy): return single values from useStoreActions --- src/components/Handle/index.tsx | 6 ++---- src/components/UserSelection/index.tsx | 8 +++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/components/Handle/index.tsx b/src/components/Handle/index.tsx index 61b245f8..44d686d5 100644 --- a/src/components/Handle/index.tsx +++ b/src/components/Handle/index.tsx @@ -15,10 +15,8 @@ const Handle = memo( ...rest }: HandleProps) => { const nodeId = useContext(NodeIdContext) as ElementId; - const { setPosition, setSourceId } = useStoreActions((a) => ({ - setPosition: a.setConnectionPosition, - setSourceId: a.setConnectionSourceId, - })); + const setPosition = useStoreActions((a) => a.setConnectionPosition); + const setSourceId = useStoreActions((a) => a.setConnectionSourceId); const onConnectAction = useStoreState((s) => s.onConnect); const onConnectExtended = (params: Connection) => { onConnectAction(params); diff --git a/src/components/UserSelection/index.tsx b/src/components/UserSelection/index.tsx index 94b32daa..1922e200 100644 --- a/src/components/UserSelection/index.tsx +++ b/src/components/UserSelection/index.tsx @@ -45,11 +45,9 @@ const SelectionRect = () => { }; export default memo(({ isInteractive }: UserSelectionProps) => { - const { setUserSelection, updateUserSelection, unsetUserSelection } = useStoreActions((a) => ({ - setUserSelection: a.setUserSelection, - updateUserSelection: a.updateUserSelection, - unsetUserSelection: a.unsetUserSelection, - })); + const setUserSelection = useStoreActions((a) => a.setUserSelection); + const updateUserSelection = useStoreActions((a) => a.updateUserSelection); + const unsetUserSelection = useStoreActions((a) => a.unsetUserSelection); if (!isInteractive) { return null;