This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-05-19
Channels
- # admin-announcements (1)
- # beginners (26)
- # boot (6)
- # cider (14)
- # cljsjs (29)
- # cljsrn (19)
- # clojure (87)
- # clojure-austin (5)
- # clojure-belgium (10)
- # clojure-brasil (2)
- # clojure-dusseldorf (15)
- # clojure-greece (17)
- # clojure-russia (51)
- # clojure-sanfrancisco (4)
- # clojure-sweden (20)
- # clojure-uk (31)
- # clojurescript (111)
- # core-matrix (2)
- # cursive (9)
- # datascript (15)
- # datomic (41)
- # dirac (1)
- # emacs (8)
- # flambo (1)
- # funcool (4)
- # hoplon (72)
- # lein-figwheel (3)
- # off-topic (2)
- # om (79)
- # om-next (2)
- # onyx (17)
- # other-languages (16)
- # re-frame (62)
- # reagent (26)
- # remote-jobs (1)
- # rum (3)
- # spacemacs (5)
- # untangled (120)
garden does not let you do that either
it wont compile with multiple keys with the same name as far as I have seen
@sbmitchell @ccann : you can do this in garden by using multiple maps (https://github.com/noprompt/garden/issues/6), for example:
1. lein new reagent-figwheel mygarden +garden
2. go to core.cljs and paste this in it
(ns mygarden.core
(:require
[reagent.core :as reagent]
[garden.core :refer [css]]
[garden.units :refer [px]]))
(defonce app-state
(reagent/atom {}))
(defn page [ratom]
(let [style
(css
[:.foo
{:background "red"}
{:background "-webkit-radial-gradient(circle, red, white, orange)"}])]
[:div
[:style style]
[:p.foo "Foobar"]]))
(defn reload []
(reagent/render [page app-state]
(.getElementById js/document "app")))
(defn ^:export main []
(reload))
3. start figwheel, lein figwheel dev
and navigate to localhost:3449
If you inspect the element, you will see both backgrounds are addedThanks so multiple maps
quite odd that is the intended structure
or thats more of a workaround
🙂 but thanks nonetheless
@gadfly361: thanks! That’s incredibly helpful. 🙂
@lewix @sbmitchell Regarding with-meta vs create-class, found this old thread: https://clojurians-log.clojureverse.org/reagent/2016-03-18.html ... see @mikethompson comments
@gadfly361: got it working, thanks again!
thanks @gadfly361 that is very helpful. I also use the form-3 style in all the components I need lifecycles. Glad to see there is a justification as far as the closed over data. I was thinking there had to be something
Yeah, same - I didn't realize it was more than aesthetic until Mike mentioned that lol
I came to this channel multiple times to ask how I can access previous props passed to a component in lifecycle handlers, now I wrote this: https://www.martinklepsch.org/posts/props-children-and-component-lifecycle-in-reagent.html
feedback welcome
how you can access previous props? Like in component-will-receive-props
where it has params [this [_ new-props]]
and you need to use (reagent/props this)
for the old ones and new-props would just be the map of new-props incoming
oh I see you are addressing if props arnt specfically a certain type like a map
I always make them maps so I guess I never really ran into that..I pretty much avoid multi-arg in favor of a single map
@sbmitchell: so all components you make have a single props
arg with an extra key for :children
?
@martinklepsch: Nope if I have components that have children I use & children
then typically in the render its used as (into [:div] children)
so the structure Im using for like a slide panel component is like...`[SlidePanel panel-prop-map [LeftView props] [RightView props]]`
I dont use the children or need to reference the children in lifecycles because they just receive their own props and update at the same level as the containing component
now if I have a more dynamic need for the children where I give them props (i.e a data wrapping component perhaps) I would indeed pass them in a :children
prop and then in the render id pass the props then
wondering if anyone has opinions on whether start-up conditions such as whether a user is logged in or whether critical data has been fetched should be coditionally checked inside of a top level component for all the view these checks are in place for, or if this should be handled at the router level ?