re-frame/docs/FAQs/Null-Dispatched-Events.md

740 B

Question

If I dispatch a js event object (from a view), it is nullified by the time it gets to the event-handler. What gives?

Answer

So there's two things to say about this:

  • if you want to dispatch a js event object to a re-frame event handler, you must call (.persist event) before the dispatch. React recycles events (using a pool), and re-frame event handlers run async. Find out more here

  • it is probably more idiomatic to extract the salient data from the event and dispatch that, rather than the js event object itself. When you dispatch pure, simple cljs data (ie. rather than js objects) testing and debugging will become easier.