Skip to content

Instantly share code, notes, and snippets.

Last active January 19, 2023 11:31
  • Star 36 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Using ref functions with reagent
;; React supports "refs" as a way for a component to get a
;; handle to its children. Classically, refs were string-based.
;; Recent versions of React support callback attributes as a
;; more elegant variant of accessing DOM notes or components.
;; This example uses a Form-3 component as per
;; For callback refs, see React's documentation
(defn my-component []
(let [!ref (atom nil)]
{:display-name "feed-ui"
(fn []
(some-> @!ref .focus))
(fn []
[list-view {:ref (fn [com] (reset! !ref com))
;; more attributes..
Copy link

Awesome! thanks! it helped me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment