Uh, when I specify a vector as “className” attribute to dom/div or other such function, the class attribute is set to the items in vector joined by , instead of a space
Use :classes
I have another issue that’s probably something obvious but I can’t nail it down:
(defsc LoginPage [this {:ui/keys [error-message]}]
{:query [:ui/error-message]
:ident (fn [] [:component/id ::LoginPage])
:initial-state {}}
(let [username (or (comp/get-state this :username) "username")]
(dom/div :.cs-gradient.h-screen.flex
(dom/input {:type "text"
:value username
:onChange #(comp/set-state! this {:username (evt/target-value %)})})
........
got this code that basically runs an input field. It starts with a username and then as you type is mutates component local state with the value. So when this loads and the input field contains the string username , there’s no error but as soon as I type in something I get hit with:
Warning: A component is changing a controlled input to be uncontrolled. This is likely caused by the value changing from a defined to undefined, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info:
this is confusing to me because clearly I am stating value and making a controlled input here???I think this is caused by this bug: https://github.com/fulcrologic/fulcro/issues/579
Well that’s a bizarre miss
Deleted a message by mistake: in routing_demo2 I look at render of LoginScreen in Root:
(contains? cfg ::LoginScreen)
(let [LoginScreen* (comp/registry-key->class ::LoginScreen)]
((comp/factory LoginScreen*) {}))
it’s always rendered with empty props, where does it get error-message it expects in props?
(defsc LoginScreen [this {:ui/keys [error-message] :as _props}]
{:query [:ui/error-message]
:ident (fn [] [:component/id ::LoginScreen])
The (ops/assign :ui/error-message "Login failed. Please try again.") seems to modify a local storage of a statechart. Also what is the benefit of running a script element that returns ops/assign compared to just using an assign element?
(transition {:event :auth/login-failed}
(script {:expr (fn [_env _data _event-name _event-data & _]
[(ops/assign :ui/error-message "Login failed. Please try again.")])}))The assign element is a shorthand, which is also useful in nested If elements, etc. If you want to structure the simple logic into the chart. script is more general and lets you do arbitrary computation, the results of which you might want to store. As far as the routing demo, I’m not looking at it right now, but on the surface it looks like a bug. I’ve been quite busy and some of these demos I’m not refining to a great level of detail.