On Monday, January 27, 2014 11:10:36 AM UTC-3, Dan Holmsand wrote:
> On Monday, January 27, 2014 2:30:57 PM UTC+1, ritchie turner wrote:
> > How i want to get an event after reagent is finished rendering a component. 
> > I want to be able to query the dimensions of a component, e.g. to center a 
> > dialog box component after I've rendered a new form into it.
> 
> Yeah, that is hardly documented at all yet, I'm afraid...
> 
> You can get React's lifecycle callbacks by attaching metadata to a component 
> function, as is done in the todomvc demo:
> 
> (def todo-edit (with-meta todo-input
>                  {:component-did-mount #(.focus (reagent/dom-node %))}))
> 
> where todo-input is a component fun, and todo-edit a new one, but with the 
> callback.
> 
> React's callbacks are documented here:
> 
> http://facebook.github.io/react/docs/component-specs.html
> 
> In Reagent they get slightly different parameters (to avoid having to use 
> this-as), and you can use dashed names instead of camelCase. The whole set 
> looks like this:
> 
> :get-initial-state (fn [this])
> :component-will-receive-props (fn [this new-props])
> :should-component-update (fn [this old-props new-props old-children 
> new-children])
> :component-did-mount (fn [this])
> :component-did-update (fn [this old-props old-children])
> :component-will-unmount (fn [this])
> 
> In your case, you'd want to use :component-did-mount, and possibly 
> :component-did-update.
> 
> Hope that helps,
> 
> /dan

Thanks Dan that worked.

R

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to