This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-27
Channels
- # bangalore-clj (1)
- # beginners (11)
- # boot (23)
- # business (2)
- # cider (43)
- # cljs-dev (65)
- # cljsjs (17)
- # cljsrn (4)
- # clojure (144)
- # clojure-austin (4)
- # clojure-berlin (3)
- # clojure-finland (4)
- # clojure-nl (2)
- # clojure-russia (13)
- # clojure-spec (73)
- # clojure-uk (42)
- # clojured (2)
- # clojurescript (166)
- # core-matrix (4)
- # cursive (24)
- # datomic (39)
- # dirac (8)
- # hoplon (97)
- # jobs (2)
- # jobs-rus (11)
- # juxt (16)
- # lein-figwheel (8)
- # leiningen (1)
- # luminus (5)
- # lumo (46)
- # off-topic (1)
- # om (39)
- # onyx (43)
- # overtone (1)
- # pedestal (3)
- # perun (6)
- # play-clj (3)
- # protorepl (14)
- # re-frame (21)
- # reagent (25)
- # remote-jobs (1)
- # ring (1)
- # robots (4)
- # rum (13)
- # specter (5)
- # untangled (72)
- # yada (62)
I normally don't write stateless React components with children in Om, but am finding a need to. I notice that instance?
does not work to figure out what type a child has. I can use the type property: (= (.-type child) ClassName)
Is that the recommended approach?
@tony.kay please clarify
what do you mean by “does not work to figure out what type a child has”?
@tony.kay oh OK I know the problem you’re having
so at that point you don’t have a component instance, but a React element
a React element is just a JS object
you want .-type
, sure
you definitely want .-type
, but you may have to make an extern for it
@tony.kay to be clear: it’ll work today, but if we start consuming React from node_modules
it might be munged by Closure
that I cannot speak to
doesn't matter. the advanced optimization will be something to keep an eye on though
happy to help!
It appears that a render
function can get information from three places:
* local sate
* props
* computed
Now, I know what to put in local state
-- basically any datta that is allowed to 'vanish' if the user closes the browser.
What I don't get is props
vs computed
-- docs talk about computed
being used for callbacks -- but where do I draw the line for:
this goes in props
vs this goes in
computed` ?
========== If I need to (1) update local state via update-state! and (2) make a callback passed to me via (om/get-computed) Should I: (1) update-state! // make-callback OR (2) do the make-callback INSIDE the update-state! ?
sorry, I meant "is there a way for the parent element to pass an initial value to a child element's local state" ?
I think what you have described is : is there a way to globally declare an localstate for a component
I thought about using computed -- but is it only passed once, or is it passed multiple times?
(initLocalState [this]
(let [{:keys [foo]} (om/props this)]
{:foo foo}))
it seems like if the computed changes something, it may be possible that the computed gets passed a 2nd time and overwrites the original inititLocalState
can you guys load up http://dodv-demos.appspot.com ? I need some advice on this om component I'm building
@anmonteiro s approach is good : ) if you need local state from props
You see a little "window" with two slider bars right? (the sliders don't work in this particular release)
so locally, I have an example where the sliders work, and the sliders have all their state stored in localState
to make that happen, should I be (1) using a om/computed + callback or (2) storing this in global state?
Full Question: 1) I have http://dodv-demos.appspot.com 2) the sliders are supposed to move up/down + left/right (but do not yet) 3) I have a local version where dragging works. 4) In local version, all state of sliders is localState 5) However, when sliers move, I need inner body to pan 6) To make this happen, should I be (1) attaching callbacks via om/computed to the sliders or (2) having the sliders om/transact! into some global state ?