This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-08-06
Channels
- # announcements (3)
- # architecture (16)
- # beginners (5)
- # cherry (1)
- # cider (3)
- # cljsrn (2)
- # clojure (54)
- # clojure-dev (11)
- # clojure-europe (14)
- # datalevin (26)
- # emacs (8)
- # helix (5)
- # honeysql (5)
- # hyperfiddle (40)
- # lsp (12)
- # malli (23)
- # missionary (7)
- # nrepl (2)
- # off-topic (18)
- # releases (2)
- # yamlscript (1)
I am trying to use a rn-sliding-up-panel in a ClojureScript app, but not sure how to convert this part:
<SlidingUpPanel ref={(c) => this._panel = c}>
The closes thing I can come up with is something like
:> SlidingUpPanel {:ref (js->clj #{(c) => this._panel = c})}
assuming you’re using reagent, you can have a https://github.com/reagent-project/reagent/blob/master/doc/CreatingReagentComponents.md#form-2--a-function-returning-a-function that creates an atom in the outer-fn:
(defn your-component []
(let [ref (atom nil)]
;; you can pass @ref to other stuff that might need it
(fn []
[:> SlidingUpPanel {:ref #(reset! ref %)}])))
alternatively, you could use (React/createRef)
, which is just
(def ref (react/createRef))
;; use (.-current ref) to access the component from elsewhere
(defn your-component []
[:> SlidingUpPanel {:ref ref}])