740 B
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 thedispatch
. 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 youdispatch
pure, simple cljs data (ie. rather than js objects) testing and debugging will become easier.