Fork me on GitHub
#fulcro
<
2018-02-03
>
maridonkers14:02:29

I'm getting an error when SSR'ing a Union (the Union works as expected in JavaScript but when I reload the page the SSR bombs out):

1. Unhandled java.lang.IllegalArgumentException
   No matching field found: displayName for class
   clojure.lang.AFunction$1

            Reflector.java:  308  clojure.lang.Reflector/invokeNoArgInstanceMember
           primitives.cljc: 3380  fulcro.client.primitives$merge_alternate_unions$merge_union__39719/invoke
Line 3380 of fulcro.client.primitives reads:
(log/warn "WARNING: Subelements of union " (.. parent-union -displayName) " have initial state. This means your default branch of the union will not have initial application state.")
Searching fulcro.client.primitives source code (Fulcro 2.1.6) for displayName reveals a reader conditional in a function (which seems to suggest it's ClojureScript only):
(defn component-name
  "Returns a string version of the given react component's name."
  [class]
  #?(:clj  (str (-> class meta :component-ns) "/" (-> class meta :component-name))
           :cljs (.-displayName class)))

tony.kay18:02:26

@maridonkers Ah, yeah, that is a problem. The warning is probably unnecessary anyway. I think it is obvious that you won’t get initial state if you don’t add initial state. I removed that and pushed it as a snapshot 2.1.7-SNAPSHOT to clojars

maridonkers18:02:36

@tony.kay Thanks. That does indeed sound obvious 🙂

mss20:02:04

hey all, how do I attach a method to a defsc component similar to the following using defui:

(defui MyComponent
  Object
  (my-method [] ...)
  (render [this]
          (my-method)))
attempted to just add it into the map of options passed to defsc (similar to a react lifecycle method) but that doesn’t seem to be working

tony.kay20:02:21

@mss :protocols [Object (method [args] …)]

mss20:02:29

amazing, thanks so much

tony.kay20:02:36

the predefined ones (in the docs string) are error-checked. Any additional have to be add the class like you would with defrecord, which is the :protocols option