Skip to content

Commit

Permalink
Separate concerns, bind function
Browse files Browse the repository at this point in the history
  • Loading branch information
viktor-yakubiv committed May 22, 2020
1 parent 3d3092a commit 860ab88
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions modules/billing/payment-required/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const emailContext = observable({
},
})

const useSync = (store) =>
const useSync = (store) => {
useEffect(
() =>
autorun(() => {
Expand All @@ -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])

Expand Down

0 comments on commit 860ab88

Please sign in to comment.