Fork me on GitHub
#fulcro
<
2020-10-25
>
nivekuil06:10:19

honestly I think a component-just-for-its-query with a pre-merge is actually pretty elegant in its own right

jlmr13:10:53

HI, I’ve just started experimenting with Fulcro (so far I really like the local reasoning that it enables) and I’m stuck with this simple component:

(defsc IdeaInput
  [this {:input/keys [idea]}] 
  {:query [:input/id :input/idea]
   :ident :input/id
   :initial-state (fn [{:keys [id]}]
                    {:input/id id
                     :input/idea "A string"})}
  (dom/div
    (dom/label "Idea: ")
    (dom/input {:value idea
                :onChange #(m/set-string!! this :input/idea :event %)})))
I would expect that typing in the input would also change the database. I can see something similar happening in this example: http://book.fulcrologic.com/#_the_function_as_a_child_pattern. When I try the above code and type something I see transactions happening in the Fulcro inspector, however the database is not updating. I’m probably missing something simple, all help welcome!

nivekuil13:10:56

In reply to @￱_￱slack￱_￱￱_￱￱_￱t03￱_￱r￱_￱z￱_￱g￱_￱p￱_￱f￱_￱r=2d￱_￱u56￱_￱r03￱_￱v￱_￱n￱_￱w:nivekuil.comHI, I’ve just started experimenting with Fulcro (so far I really like the local reasoning that it enables) and I’m stuck with this simple component:&lt;code&gt;(defsc IdeaInput&lt;br /&gt; [this {:input/keys [idea]}] &lt;br /&gt; {:query [:input/id :input/idea]&lt;br /&gt; :ident :input/id&lt;br /&gt; :initial-state (fn [{:keys [id]}]&lt;br /&gt; {:input/id id&lt;br /&gt; :input/idea "A string"})}&lt;br /&gt; (dom/div&lt;br /&gt; (dom/label "Idea: ")&lt;br /&gt; (dom/input {:value idea&lt;br /&gt; :onChange #(m/set-string!! this :input/idea :event %)})))&lt;/code&gt;I would expect that typing in the input would also change the database. I can see something similar happening in this example: <http://book.fulcrologic.com/#_the_function_as_a_child_pattern>. When I try the above code and type something I see transactions happening in the Fulcro inspector, however the database is not updating. I’m probably missing something simple, all help welcome!jlmr: does it behave differently with m/set-string!, one exclamation point?

jlmr13:10:34

I’ve tried that already and it didn’t change anything

nivekuil13:10:03

In reply to @￱￱slack￱￱￱￱￱￱t03￱￱r￱￱z￱￱g￱￱p￱￱f￱￱r=2d￱￱u56￱￱r03￱￱v￱￱n￱_￱w:nivekuil.comI’ve tried that already and it didn’t change anythingif you can see transactions happening in the inspector, what's the value of the transaction? under the Transactions tab

nivekuil13:10:02

In reply to @.:nivekuil.comif you can see transactions happening in the inspector, what's the value of the transaction? under the Transactions tabin that book example it becomes (com.fulcrologic.fulcro.mutations/set-props {:block/name "a"}) if I change "A Block" to "a" for example

jlmr16:10:56

@U797MAJ8M sorry, wasn’t at my desk. Transaction looks like this: (com.fulcrologic.fulcro.mutations/set-props {:input/idea "A stringa"})

jlmr16:10:14

When I add an a to the string in the input

jlmr16:10:50

However in the transactions tab, the details for this transactions show:

Diff added
nil
Diff removed
nil

holyjak16:10:01

Maybe look at the code of the mutation, what it actually does? Add some logs to it?

jlmr17:10:30

@U0522TWDA the code for the mutation is provided by fulcro. Pretty sure it is the generated by mutations/set-string!!

eoliphant17:10:03

could you share the code where the input is used? Common gotcha in Fulcro is missing wiring somewhere between the component in question and the root

jlmr17:10:37

Sure, it’s my first experiment with Fulcro, so there isn’t much code yet. This is the Root component:

(defsc Root
  [_this {:keys [input ideas]}]
  {:query [{:input (comp/get-query IdeaInput)}
           {:ideas (comp/get-query IdeaList)}]
   :initial-state (fn [_] {:input (comp/get-initial-state IdeaInput {:id 1})
                           :ideas (comp/get-initial-state IdeaList {:id 1})})}
  (dom/div
    (ui-idea-input input)
    (ui-idea-list ideas)))

eoliphant17:10:43

hmm. that looks correct. Does the database look correct when you load the page? something that has at least

eoliphant17:10:51

{:input [:input/id 1]
 :input/id {1 {:input/id 1 :input/idea "A string"}}

jlmr07:10:29

Those things are indeed in the db

tony.kay16:10:46

Did you compose that input to the root?

tony.kay16:10:55

initial state and query have to compose to root

Mr. Savy17:10:04

ok I'm a bit late but I made a gist of the issue I mentioned earlier. link: https://gist.github.com/AlbertSnows/25c41d887ebe0eb01e9eea868a362ef6 The output is at the bottom, but as a recap essentially the issue is that my route component has two sub-components, A and B, but when the data is passed through it's getting B twice. I haven't been able to figure out why.

stuartrexking23:10:12

Anyone aware of a bug when using Fulcro Inspect with Fulcro 3.4.3 where the database values in inspect don’t update. The underlying values are updated, but the way the db is rendered by FI doesn’t show the state changes. I can transact changes in the REPL, it’s just the db doesn’t update in FI. If I roll back to 3.0.3 it works fine.

stuartrexking23:10:33

This sounds like the same issue @jlmr might be having above.

stuartrexking23:10:47

If I compile and the install the extension locally everything works with 3.4.3. If I use the version of Fulcro Inspect from the Chrome Web Store, which was updated on 1 June 2020 but reports a version of 1.0.21 then it doesn’t work.

stuartrexking23:10:39

When I compile and install locally the extension version is 3.0.2

stuartrexking23:10:52

But Chrome Web Store version is 1.0.21

stuartrexking23:10:47

:man-shrugging:

tony.kay16:10:54

I have not updated the one in the store because the new version breaks for old apps. I’ll update it at some point. Very busy

Michael W23:10:19

@stuartrexking See https://github.com/fulcrologic/fulcro-inspect/releases/tag/chrome-3.0.0-RC1 as of 3.4.0 there is a new chrome extension that hasn't been pushed to the Chrome store yet.