I have a few UI components (e.g. a toast message popup controller) that I need to find an appropriate place to store a react Ref, any suggestions? I've made the mistake of storing them in app-db and .. that does not seem to be the place to put them 😄
For the truly global ones, would it make sense to just write a local JS function to store the ref and deal with interop to call it?
why not in the app db?
I've run into some weird issues when I put some refs in app-db, including browser tabs that just get stuck, I think becuase of of the size of some of the elements they refer to, I end up with fairly large js objects in the app-db and that seems to be trouble. Some of the other components that are simpler references to like single dom nodes seem to be fine in app-db.
My go-to is to create an atom using with-let:
(defn my-component
[]
(reagent.core/with-let [el-ref (atom nil)]
[:div {:ref #(reset! el-ref %)
:on-click #(when @el-ref
(.someMethod @el-ref))}
"Click Me"]))Note that this is a simplified example. Some might prefer to move the .someMethod call to an effect that is invoked by an event that is dispatched by the on-click handler.
I myself prefer to use react/createRef to create a ref inside r/with-let, and use it as :ref ref and (when-let [node (.-current ref)] ...).
are there any dev tools that will let me search by sub key? Like goto definition but for subs?
🤦♂️ writing this out made me think of new search terms and I've found that it just uses the normal search functions. Neat! Yay!
Hi, Is it inadvisable to use re-frame for production if one does not know React? More specifically, re-frame seems really interesting and I'm contemplating learning it. However, I am not interested in learning React right now; from what I've heard React has a steep learning curve and I'd rather invest my learning hours in Clojure and not React.
It's not black-and-white like that. Knowing React would be helpful but isn't strictly necessary in general. Some specific workflows might require knowing some of it though.
Would the React knowledge be basic and useful to make the most out of re-frame, or is it more of a skill to keep in the back of your pocket for debugging and edge-case quirks?
What re-frame itself brings to the table is completely orthogonal to React. But re-frame depends on Reagent, and Reagent depend on React. So any knowledge of React would help its wielder with Reagent but not with re-frame. And it's both - anything you can know to make the most out of something is usually also useful during debugging.
This makes me wonder, why is there no implementation agnostic re-frame? I really enjoy its flux pattern, but the dependency on the reagent atom is kind of a bummer, it would be great to use it within any other context where reagent dependency is not needed nor desired
> why is there no implementation agnostic re-frame? There is. :) Or even are, IIRC.
Some links from my notes: • https://github.com/metosin/si-frame • https://github.com/ferdinand-beyer/refx • https://github.com/factorhouse/rfx
Using reframe/reagent make development much simpler than using something like react/redux , so just basic understanding of react is required
I have a few events that seem to skip being logged by re-frame-10x.. anyone have any experience with this problem? I can throw a println and see the app is running the event handler code when dispatched, but it just never shows up in event log (definitely using fn-trace) ... pulling my hair out trying to see what could be wrong
i have the same issue in firefox