From 860ab8822989490965e282040ac369e1cc84ce3d Mon Sep 17 00:00:00 2001 From: Viktor Yakubiv Date: Fri, 22 May 2020 12:59:43 +0300 Subject: [PATCH] Separate concerns, bind function --- modules/billing/payment-required/data.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/billing/payment-required/data.js b/modules/billing/payment-required/data.js index 08c6d034b..95b0c1078 100644 --- a/modules/billing/payment-required/data.js +++ b/modules/billing/payment-required/data.js @@ -62,7 +62,7 @@ const emailContext = observable({ }, }) -const useSync = (store) => +const useSync = (store) => { useEffect( () => autorun(() => { @@ -75,13 +75,18 @@ const useSync = (store) => // it should be expected. globalContext.user = store.user globalContext.organisation = store.organisation - - emailContext.actionUrl = store.contactUrl - emailContext.send = store.sendContactRequest }), [store] ) + useEffect(() => + autorun(() => { + emailContext.actionUrl = store.contactUrl + emailContext.send = store.sendContactRequest.bind(store) + }) + ) +} + const useFormAction = () => useObserver(() => [emailContext.actionUrl, emailContext.send])