Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defonce mypos (reagent/atom {}))
- (defn getsize [comp]
- (let [ node (reagent/dom-node comp)
- x (.-x (.getBoundingClientRect node))
- y (.-y (.getBoundingClientRect node))]
- {x y}))
- (defn my_component []
- (let [state (reagent/atom {})] ;; you can include state
- (reagent/create-class
- {:component-did-mount
- (fn [comp]
- (swap! mypos #(getsize comp)))
- :display-name "complex-component"
- ;; note the keyword for this method
- :reagent-render
- (fn [] [:div [:b "Initial position: " @mypos]])})))
- (defn page []
- [:div [my_component]])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement