This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-10-31
Channels
- # aleph (1)
- # announcements (2)
- # beginners (105)
- # braveandtrue (1)
- # cider (61)
- # clara (47)
- # cljdoc (29)
- # cljs-dev (5)
- # clojure (61)
- # clojure-austin (14)
- # clojure-brasil (1)
- # clojure-india (3)
- # clojure-italy (4)
- # clojure-mexico (1)
- # clojure-nl (2)
- # clojure-spec (37)
- # clojure-uk (95)
- # clojurescript (73)
- # cursive (12)
- # data-science (1)
- # datomic (26)
- # duct (10)
- # emacs (5)
- # fulcro (47)
- # hoplon (6)
- # hyperfiddle (3)
- # jobs-discuss (3)
- # kaocha (2)
- # leiningen (3)
- # nrepl (8)
- # off-topic (3)
- # onyx (2)
- # re-frame (31)
- # reitit (16)
- # shadow-cljs (36)
- # spacemacs (46)
- # specter (16)
- # tools-deps (13)
- # yada (22)
@pvillegas12 I think you copied serial? false
from the demo when making the file upload remote
I do :face_with_hand_over_mouth:
That is there to support parallel uploads of files, but it make that remote incompatible with ptransact!
making a remote automatically parallel means that any number of requests can go at once, and the defer relies on the serial blocking of the remote
I’m releasing 2.6.12 with a built-in error message to the console when this mistake is made
oh nice
I want to construct a presentational component (receives props and renders, nothing stateful) but I’m running into wanting to have UI only state in that component. I tried using a defsc
and I can see the state changing in fulcro inspect but the component does not re-render based on that state change.
@pvillegas12 so i’m a little confused, could you provide a gist of the component?
if the component is not stateful, and you don’t need any react lifecycle methods, then you could just make it a function that takes arguments and returns dom elements, that’s very lightweight and simple
it’s not uncommon to have helper functions for that sort of thing
(defn labeled-input
[{:keys [id className required placeholder help warning error success
input-generator]
:as attrs} label]
(let [input-group-classes (str (if required "required") (if error "error"))
help (first (keep identity [error warning success help]))
help-id (str id "-help")
attrs (cond-> (dissoc attrs
:help :warning :error :required
:success :input-generator)
help (assoc :aria-describedby help-id))]
(div :$field {:className input-group-classes}
(dom/label
(dom/span label)
(when help
(dom/span {:id help-id} html/nbsp (str "(" help ")"))))
(if input-generator
(input-generator attrs)
(dom/input (clj->js attrs))))))
@currentoor in plain react I would make a component that uses setState
for changing a bit of state that is only concerned with the UI
in this case, it is a ui/currently-selected-model
ah i see so it does have state, but you don’t care about it
right
i would argue in most cases it’s still better to give it an ident and put it in app state
think about how you would program on the server
I gave it an ident too, but when I changed ui/currently-selected-model
the fulcro inspect state changed, but the component did not get re-rendered
if you had some temporary state you need to track for a short period of time, wouldn’t you prefer having in the database? rather than some other mutable cell
my problem is the re-rendering
@pvillegas12 did you get to the bottom of it ?
I made a workaround solution, the child component I was making needed the queried props from the parent. I couldn’t quite get the copying over so the state I needed I stuffed into the parent
ahh oky 🙂 Was u're use-case something like: component has :query [:nested-stuff]
, you do a transact in the child updating the data but it does not refresh ?
Imagine this, I have a parent component that queries for all attributes of a given model. I want to break up that component, using presentational components. Normally you pass down functions to affect the parent’s state to leave the child component presentational. However, in this case, I wanted to experiment with a stateful component, sharing the state from the parent but having one field that controlled the UI (nothing to do with the backend). I have to put that state somewhere in fulcro so I tried to have an ident for the component. I saw the state change within fulcro inspect but it did not trigger a re-render. That is because I was passing in the props from the parent, not a (get-query child-component)
.
The problem is I don’t have a separate query per se
it is a UI ui/selected-model
kind of element in the fulcro db
placing it in the parent solved it, I was exploring how to do the above without polluting the parent state (if there are many children, the parent will have the state that controls everything which becomes unwieldy depending on the component)
But for the refresh have you tried a) passing the this
of the parent & running the transact with the this from the parent b) adding a fallowon read with a key from the parent ?
ah i see
well where is the mutation that triggers this update being called?
inside the component
hmm so when you call transact you’re using this
from the component you want to re-render?
however, when I call the factory function
I’m passing in props from the parent
(uses the same props)
so I don’t pass the normal (prim/get-query component-name)
that might be a problem
in fact i think the book says not to do that
if a component depends on data from app state (a component with an ident means it does) then it should have a query and only get the props for that query
My problem is that I have a big data blob I don’t want to be copying to diferent edges in the graph
unless structural sharing solves this
why? that’s pretty cheap operation with immutable data structures
i would at least try it
@wilkerlucio http://book.fulcrologic.com/#_interfacing_with_alternate_network_protocols doesn’t seem to be inline with pathom RC1. I”m getting complaints that the remote mutation I want to run doesn’t exist. Any ideas?