Fork me on GitHub

hi, I'm relatively new to clojurescript and we've used reagent and re-frame to build our apps (on electron). Both are teriffic libraries! While using reagent, we've successfully used external js components using Form-3 style components (creating a class with lifecycle methods). In reagent, we pass the app-state or a cursor when creating the component and later refer to it using 'reagent/children` call. While using re-frame though, can somebody point me to a sample of how to use subscriptions to access the state in life-cycle methods like :component-did-mount etc ?


I don't have much time ... so quickly ... 1. in the Form2 parent component, use a (subscribe [:something]) to obtain a reactive value (called say, x) 2. make a Form3 child component, which has life-cycle methods 3. in the parent, render the child passing the dereferencing x [child @x] So in effect, pass a changable value into the child. Value, not ratom! When the value changes the parent will be rerendered, passing in the new value to the child. That will trigger lifecycle fns on the child.


Hope that helps


Thanks Mike, I did try something like that but not exactly..I think the problem is that we're using using the :render method instead of the :reagent-render method. I notice with :reagent-render we get access to all the args..

Petrus Theron15:07:12

How can I focus a re-com input field on mount? I have this helper which works for root input elements:

(def focused                                     
  (with-meta identity
    {:component-did-mount #(.focus (dom-node %))}))
Which can be used like so: [focused [:input {:type "text"}]] How would I accomplish the same thing in re-com?


@petrus: could you use the standard autofocus attribute

     :model  "hello"
     :attr {:auto-focus true}]