Fork me on GitHub
#fulcro
<
2018-10-31
>
tony.kay00:10:12

@pvillegas12 I think you copied serial? false from the demo when making the file upload remote

pvillegas1200:10:17

I do :face_with_hand_over_mouth:

tony.kay00:10:30

That is there to support parallel uploads of files, but it make that remote incompatible with ptransact!

tony.kay00:10:11

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

tony.kay00:10:08

I’m releasing 2.6.12 with a built-in error message to the console when this mistake is made

🙂 8
pvillegas1213:10:33

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.

currentoor16:10:51

@pvillegas12 so i’m a little confused, could you provide a gist of the component?

currentoor16:10:14

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

currentoor16:10:36

it’s not uncommon to have helper functions for that sort of thing

currentoor16:10:32

(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))))))

pvillegas1216:10:46

@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

pvillegas1216:10:15

in this case, it is a ui/currently-selected-model

currentoor16:10:30

ah i see so it does have state, but you don’t care about it

currentoor16:10:51

i would argue in most cases it’s still better to give it an ident and put it in app state

currentoor16:10:07

think about how you would program on the server

pvillegas1216:10:43

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

currentoor16:10:56

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

pvillegas1216:10:10

my problem is the re-rendering

claudiu06:11:33

@pvillegas12 did you get to the bottom of it ?

pvillegas1212:11:08

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

claudiu12:11:42

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 ?

pvillegas1213:11:27

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).

pvillegas1213:11:45

The problem is I don’t have a separate query per se

pvillegas1213:11:01

it is a UI ui/selected-model kind of element in the fulcro db

pvillegas1213:11:55

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)

claudiu13:11:22

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 ?

currentoor16:10:37

well where is the mutation that triggers this update being called?

pvillegas1216:10:44

inside the component

currentoor16:10:21

hmm so when you call transact you’re using this from the component you want to re-render?

pvillegas1216:10:40

however, when I call the factory function

pvillegas1216:10:44

I’m passing in props from the parent

pvillegas1216:10:48

(uses the same props)

pvillegas1216:10:03

so I don’t pass the normal (prim/get-query component-name)

currentoor16:10:09

that might be a problem

currentoor16:10:24

in fact i think the book says not to do that

currentoor16:10:19

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

pvillegas1216:10:27

My problem is that I have a big data blob I don’t want to be copying to diferent edges in the graph

pvillegas1216:10:43

unless structural sharing solves this

currentoor16:10:57

why? that’s pretty cheap operation with immutable data structures

currentoor16:10:09

i would at least try it

currentoor16:10:51

or only query for the things you need out of that blob in your modal

👍 4
levitanong19:10:50

@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?