question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pass store as third argument to the event handler

See original GitHub issue

Currently if you want to dispatch an event from inside an event handler you need to have the store on scope by using a closure. If I want to have my event handler in a separate file, then I cant use closures to have access to the store. A way of solving this is by passing the store as the third argument to the event handler, something like

type EventHandler<State,Event> = (currentState: State, event: Event, store: Store) => Partial<State> | undefined

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
aicommented, Oct 24, 2020

The fix was released in 3.1

0reactions
octav47commented, Oct 24, 2020

PR #130

Read more comments on GitHub >

github_iconTop Results From Across the Web

Day 10: Passing Arguments to Event Handler in React - Medium
We will see that below in our example. There are two ways to pass arguments, via the Arrow function and the Bind method....
Read more >
To pass a parameter to event listener in AS3 the simple way ...
Passing a parameter directly to the event handler is not possible. The best approximation is by using a function factory method, IMO.
Read more >
Passing Arguments to Event Listeners in JavaScript
Passing arguments to an event handler can be particularly useful when the handler is reused for different events. For example, we want to...
Read more >
Passing Arguments to Event Handlers - TutorialsWebsite
Passing arguments to event handler Using Bind Function or Method. You don't need to pass “e” (React Event Object) as an argument. With...
Read more >
AWS Lambda function handler in Node.js
The runtime passes three arguments to the handler method. The first argument is the event object, which contains information from the invoker.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found