This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-05
Channels
- # announcements (17)
- # architecture (5)
- # babashka (12)
- # beginners (155)
- # calva (18)
- # chlorine-clover (2)
- # cider (57)
- # circleci (2)
- # clojure (151)
- # clojure-europe (4)
- # clojure-gamedev (20)
- # clojure-italy (18)
- # clojure-nl (4)
- # clojure-norway (3)
- # clojure-spec (8)
- # clojure-uk (95)
- # clojurescript (70)
- # core-async (68)
- # css (3)
- # data-science (13)
- # datascript (1)
- # datomic (16)
- # docker (2)
- # figwheel-main (41)
- # fulcro (34)
- # graalvm (6)
- # graphql (7)
- # jobs (14)
- # joker (2)
- # kaocha (1)
- # leiningen (2)
- # malli (3)
- # midje (2)
- # overtone (1)
- # reagent (8)
- # reitit (6)
- # ring-swagger (1)
- # schema (2)
- # shadow-cljs (6)
- # spacemacs (3)
- # specter (5)
- # timbre (3)
- # uncomplicate (1)
@tony.kay it is in the doc-string, that is where I found it. And if I understand you correct we can use the doc-string as the definitive guide as to what the public API is?
“definitive” is a strong word for free open source. I strive to make all documentation as correct and complete as possible. If it is mentioned anywhere and works, then it is as official as it gets.
So, there is a ton of variability in the question. Bootstrap is CSS, and it also has non-react js components. There is not a great way to use the js components (though I wrote some wrappers for the css at one point if you look in F2 source or earlier…abandoned, but semi-working). You are more likely asking about how to do form state and interaction, which has nothing to do with bootstrap. The book goes into quite a bit of detail on using Form State helpers. In your example below you seem to want a modal, which is whole other thing that has nothing in itself to do with forms other than they sometimes “hold” forms.
But this is probably even lack of bootstrap/react understanding rather than fulcro problem itself..
:onChange (fn [e] (comp/transact! this [(ui-mutations/update-add-connector-modal-form
#:add-connector-modal{:id id
:field (.-id (.-target e))
:value (.-value (.-target e))})]))
Hello, I have component that I have set initial state on it, it gets normalized in db alright but it doesn't show up in the props any help or ideas please 🙂 ?
did you destructure them and pass them through??? There is nothing magic about the props…they are a tree passed from root
I'm routing to the main sub component that have initial-state
, so it acts like root (?) in that context, maybe because of that??
You have a point, I tried to shrink code to it's basic.
;; router
(dr/defrouter ProjectPanelRouter [this props]
{:router-targets [ActionList]} )
;; where we route to our component with initial state
(defsc ProjectPanel [this {:project-panel/keys [router] :as props}]
{:query [{ :project-panel/router (comp/get-query ProjectPanelRouter) } ]
:ident (fn [] [:component/id :project-panel])
:initial-state {:project-panel/router {}}
:route-segment ["project-panel"]
(dom/div
(ui-button {:onClick #(dr/change-route this (dr/path-to ActionList {:action-list/id (random-uuid)} ))})
(ui-project-panel-router router))})
;; the target route (with init state)
(defsc ActionList [this {:action-list/keys [id actions] :as props}]
{:query [:action-list/id {:action-list/actions (comp/get-query ActionRow)}]
:route-segment ["action-list" :action-list/id]
:ident :action-list/id
:initial-state (fn [params] {:action-list/id (random-uuid)
:action-list/actions [(comp/get-initial-state ActionRow {:owner "Owner" :action "Action" :id 1})
(comp/get-initial-state ActionRow {:owner "Owner2" :action "Action2" :id 2})]})
;:initial-state {:project/id 1 }
}
(map ui-action actions))
;; child component
(defsc ActionRow [this {:action/keys [action owner status due-date] :as props}]
{:query [:db/id :action/action :action/owner :action/status :action/due-date]
:ident [:action/id :db/id]
:initial-state (fn [{:keys [owner action id]}] {:action/owner owner :action/action action :db/id id})}
(dom/ul
(dom/li {} action)
(dom/li {} owner)))
I have also noticed that using lambda
for initializing the state of the router (in component where we route) doesn't work as the template
one. Thank you 🙂I have noticed when having ident that depends on props, it doesn't work (props don't get passed from init state), having an ident which doesn't use props did the trick (ActionList comp) but still don't get it, why can't props that come through init state can't be used in the ident.
so, props do get passed from init state, and the ident function really must use the data that is passed in props or they cannot work. I don’t understand that statement. OH, I think you misunderstand the diff between initial state as a lambda and as a map.
The equiv initial state in ActionList is:
:initial-state {:action-list/id (random-uuid)
:action-list/actions [{:owner "Owner" ...} { :owner "Owner2" ...}]}
perhaps that was your problem? I’m pretty sure there is a misunderstanding in there somewhere, but the code as you show it above looks fine as far as I can tell.
how are people handling tracking routing history in fulcro apps? seems like I can just transact a mutation to store a route path on the app state in the will-enter
fn of my component and wherever else the route changes. anything I’d be missing with that approach?
or are you not using the URL to track history? You’re suggestion has merit in some circumstance.
I assumed that a router just passes through whatever props it gets (possibly dissocing it's own) to its targets so that if I do (ui-router1 (assoc router :xxx 1))
I would get (= 1 (:xxx props))
in the routing target. Or not?
the router has it’s own props, and it is never appropriate to do that to props that come from a query (because of the possibility of localized UI refresh of the child, which would be missing that assoc)
Thank you! So I guess what is happening in practice, for the first target, is something like (pseudocode):
((factory MyFirstTarget) (merge computed-props (:alt0 props)))
so that we do pass down the props from the query + computed props. Right?If you just follow that link and read the macro code, you can quickly see exactly what it is doing…computed is carried as a special prop if it is to one (a map) and as metadata if to-many….but in either case Fulcro knows that the data was computed and can re-supply it on targeted refresh.
I would dispute the "can quickly see" part 😅 I have studied the code yesterday (before asking) but failed to grok it fully. Thank you!
agreed 😄
if you’ve read and understood the reason for computed
, that is, then it is a single line of code in the macro that I linked you to, which is just ferrying computed.
Yeah, I read the line but lacked too much background knowledge to understand it.
I read about computed properties in the book but still...
Computed props, however, I think I pass through, so you can use (ui-router (comp/computed router {:xxx 1}))
yeah, verified: https://github.com/fulcrologic/fulcro/blob/develop/src/main/com/fulcrologic/fulcro/routing/dynamic_routing.cljc#L578