This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-12
Channels
- # announcements (1)
- # aws (1)
- # babashka (63)
- # beginners (108)
- # calva (12)
- # cider (6)
- # cljdoc (2)
- # cljsrn (33)
- # clojure (150)
- # clojure-europe (28)
- # clojure-nl (13)
- # clojure-spain (1)
- # clojure-spec (8)
- # clojure-uk (25)
- # clojurescript (16)
- # conjure (7)
- # cursive (7)
- # datomic (15)
- # duct (2)
- # eastwood (2)
- # figwheel (1)
- # figwheel-main (1)
- # fulcro (6)
- # graalvm (1)
- # graalvm-mobile (1)
- # helix (6)
- # honeysql (23)
- # integrant (6)
- # introduce-yourself (4)
- # jobs (10)
- # lsp (132)
- # malli (4)
- # meander (1)
- # membrane (1)
- # off-topic (223)
- # pathom (23)
- # pedestal (3)
- # re-frame (18)
- # reagent (13)
- # releases (1)
- # remote-jobs (2)
- # shadow-cljs (68)
- # tools-deps (217)
- # vim (19)
- # xtdb (79)
I am leaning towards making Helix the basis of my new CLJS+RN library based on my own state management library, and I am still wrapping my head around RN itself so this may be wrong, but I think I need to use some form of create-class to be able to force updates when my state management lib sees the need. This doc is great https://github.com/lilactown/helix/blob/master/docs/creating-components.md but ends up with class components as "WIP". Is there any progress on that? I will keep staring at RN to see if a supervising engine can force the re-render of functional components -- hints welcome! 🙏
hey kenny! i'll read through the issue you created and your comments on helix-todo-mvc this afternoon.
I will reply re: classes- with hooks, you should not need classes except if you are trying to build an https://reactjs.org/docs/error-boundaries.htmly
there's a macro for defining classes called defcomponent
in helix.core but I just haven't documented it
the way that you would have your state management lib trigger a render is by using a custom hook in the body of the component listening to the observable that updates the state using some other hook. helix.hooks/use-subscription
can cover this use-case in stable react versions today. here's a rough sketch:
(defhook use-observable
[rx]
(hooks/use-subscription
(hooks/use-memo
[rx]
{:get-current-value #(deref rx)
:subscribe (fn [callback]
(let [unsub (subscribe! rx callback)]
;; function to call to unsubscribe when unmounting or `rx` changes
unsub))})))
(defnc some-component
[]
(let [user-name (use-observable user-name-rx)]
(d/div "Hello, " user-name)))
Awesome. I had my eyes on the error-boundary example, thought I saw the control I needed, but perhaps it would be less brittle to use hooks. I suspect performance will be excellent since they work so hard on that. Thx, @lilactown!