This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-15
Channels
- # announcements (2)
- # babashka (137)
- # beginners (96)
- # calva (3)
- # cider (11)
- # clj-kondo (8)
- # cljs-dev (161)
- # cljsrn (21)
- # clojure (78)
- # clojure-europe (47)
- # clojure-france (1)
- # clojure-losangeles (1)
- # clojure-nl (4)
- # clojure-spec (24)
- # clojure-uk (9)
- # clojuredesign-podcast (4)
- # clojurescript (39)
- # conjure (2)
- # core-async (27)
- # cursive (36)
- # datomic (54)
- # emacs (6)
- # figwheel (9)
- # figwheel-main (46)
- # fulcro (25)
- # graalvm (8)
- # helix (30)
- # hoplon (6)
- # hugsql (3)
- # jobs (5)
- # leiningen (7)
- # luminus (12)
- # nrepl (20)
- # off-topic (20)
- # pedestal (16)
- # re-frame (14)
- # reagent (3)
- # reitit (3)
- # remote-jobs (5)
- # rum (25)
- # shadow-cljs (60)
- # spacemacs (10)
- # vim (2)
- # xtdb (36)
What's the idiomatic way to have a child component return something for the parent component to use?
Depends on what you are trying to achieve
If it's something other than hiccup/UI, then normally you'd pass a callback into the child component
Keep the state in the parent and pass it down to text area
That's what I had right now, though I guess things are a bit ugly. Because I'm trying to access the code mirror value, where code mirror is created in the did-mount function. And the state on defcs of the render function runs before did-mount.
Pass the value and a callback that takes a new value and updates the state
That's a common practice in React
I see, for that you can assign a listener onto code mirror instance and call the callback there
That should be a part of codemirror API, I don't know exactly, just an event handler that is called on every change
Ah ya, there is a change event handler. I guess I thought since I only care to grab the value when someone clicks a button. And my parent component is basically a combination of codemirror + button. My thought was to have in the on-click of button just grab the value. So I thought surely I can somehow return the codemirror instance to the parent so I can use it in the button on-click
But say I did use the on-change event for code mirror. I'm still confused how I'm supposed to pass the callback into the did-mount ?
lifecycle mixins take rum state where you can lookup args
Also if you are using latest rum, same can be done a bit easier with hooks
Yes, it is