Fork me on GitHub
#fulcro
<
2018-04-13
>
Daniel Hines02:04:35

I'm getting this error the first time the fulcro easy server starts up:

ERROR [fulcro.server:303] : java.lang.IllegalArgumentException: No method in multimethod 'read-root' for dispatch value: :surveys Parser error:
 {:status 500, :body {:type "class java.lang.IllegalArgumentException", :message "No method in multimethod 'read-root' for dispatch value: :surveys"}
When I run (restart) at the repl, it fixes it, so I assumed it was some sort of race condition. But it happens in a production build as well, which just crashes the app. Any ideas?

Daniel Hines03:04:13

Fixed it. The problem was the obvious one: I wasn't requiring the file that had defquery-root. @tony.kay, I was just following along with fulcro-todomvc though - it doesn't look like fulcro-todomvc.api is ever required anywhere. Is that intentional or a bug?

tony.kay05:04:37

@d4hines if it really isn't included, then how is it working?

tony.kay05:04:08

doesn't matter where it gets required, just as long as something requires it that is also required (transitively) from the entry point

tony.kay05:04:05

All mutations and queries are just multimethods behind the scenes (which are just maps from dispatch keys to functions)..the def calls just add entries to the map (which is what the defmulti creates)

Daniel Hines10:04:47

@tony.kay I was asking myself that same question! My eyes just missed that line. Thanks!

exit214:04:37

so defui -> defsc?

exit214:04:19

I’m at that phase now after fixing all the require issues 🙂

tony.kay14:04:01

realize that defsc is error-checked, so it may complain if you have certain things wrong that were non-harmful at runtime

troglotit15:04:23

It complains that Object(list) is not valid React child

OliverM15:04:07

@troglotit Why have you quoted the forms in each branch? And nested them inside a list? Unevaluated components won't be valid children (as the error complains) and AFAIK they should be nested in a container component like a span or div if you're trying to render multiple components (the latest React version changes this but I haven't used it in fulcro)

troglotit15:04:16

quoted them because otherwise it’d function call 🤷 .

troglotit15:04:00

nested them inside list because if-clause takes two expressions

troglotit15:04:07

but in React you always could <div>{true?<div/><div/>:""}</div> - that’s what I’m trying to do

troglotit15:04:38

not passing multiple elements via components

tony.kay15:04:33

@troglotit nope…the quoting is just wrong. If you want a list of them, use a vector (unquoted)

tony.kay15:04:12

and since you’re using low-level js components, you will probably need to put #js in front of that.

exit216:04:20

I have defui’s that had signatures as follows, but that doesn’t seem to work with defsc:

exit216:04:33

(defsc RadioGroupControl
  f/IReactKey
  (react-key [T {:keys [key]}]
    (or key (f/unique-react-key)))

  IFormControl etc...

exit216:04:21

this gives a syntax error

tony.kay19:04:07

@njj use the :protocols option

tony.kay19:04:18

it’s not a defui, it’s a whole new syntax

tony.kay19:04:30

(defsc RadioGroupControl [this props]
  {:query [:prop]
   :ident [:table :prop-of-id]
   :protocols [f/IReactKey
                      (react-key ...)]
  (dom/div ...))
You only need protocols for non-Fulcro protocols…the rest have options in the options map

tony.kay19:04:10

and react keys go on the factory: (prim/factory RadioControlGroup {:keyfn (fn [props] ...)})

tony.kay19:04:24

see the docstring and the Developer’s Guide

exit219:04:04

thanks tony

tony.kay20:04:44

@njj welcome. how is it going?

exit220:04:29

@tony.kay so far so good! just a few hiccups here and there - mostly now I think its just signatures of various functions