Fork me on GitHub
#fulcro
<
2021-07-07
>
Björn Ebbinghaus14:07:58

I have a component from a library, that is calling React.cloneElement() on one of my (hook-)components with extra js-props. But I can't access these js-props with comp/get-raw-react-prop , with a non-hooks component it works fine. Is this a bug or do I have to do something different?

tony.kay15:07:58

Try (this-as v (.-props v)) and see what you get

tony.kay15:07:31

Interop, esp with libs that control things like that, can be fiddly...probably a bug, but not sure where

Björn Ebbinghaus06:07:20

(this-as v (.-props v)) => undefined 😞 But… It's only a problem in function components. There is no this.

tony.kay13:07:45

ah right, but that might be the rub...a lot of Fulcro was written when there were only components as classes

tony.kay13:07:05

So, likely to be a bug or two around that. Fulcro nests its own props under the raw js props, but passes only the fulcro portion through...ah, yeah, I'm hacking "this" in the hooks side, and I even left a comment in the docstring: "

You should *not* use the returned `this` directly,
as it is a placeholder.

tony.kay13:07:49

Just to be clear, are you using defsc with use-hooks? or are you using the new raw components support with hooks (no defsc)?

Björn Ebbinghaus14:07:05

defsc with user-hooks, yes

tony.kay15:07:31

Do you know how to use deps/shadow-cljs to include Fulcro source in your compilation, so you can try hacking on it?

tony.kay15:07:05

This sort of thing, but with only Fulcro (not all the RAD stuff): https://github.com/fulcrologic/fulcro-rad-demo#running-from-source If you could do that, then I could point you at some things to try

tony.kay15:07:58

e.g. shadow-cljs -A:f3-dev server with that f3-dev alias in your own global deps.edn, with the correct source path to a clone of the Fulcro repo

tony.kay15:07:51

If you use IntelliJ you can also add Fulcro as a module to IntelliJ (just hit the + in the Clojure Deps tab and point at Fulcro's deps.edn). This of course is just a convenience...editing the source of Fulcro at this point with any editor will cause shadow to recompile your project with the checked-out source

tony.kay15:07:36

in configure-hooks-component! you could try using low-level js bind to set this to a js object with props...that's one way of hacking it, since defsc is sort of supposed to act like a class...don't love that...if you see a better way, feel free to explore

tony.kay15:07:49

I don't have the cycles at the moment to fully analyze

Björn Ebbinghaus15:07:40

Thanks, I will look into this, if I find the time to do so. For now, I circumvented the problem by using a wrapper component.

Björn Ebbinghaus08:07:12

@U0CKQ19AQ btw In com.fulcrologic.fulcro.raw.components:692 there is a log/spy :info. Looks like a mistake, and it's too small for an own MR. 🙂

💩 3
Tyler Nisonoff14:07:30

Anyone know how to reset form-state with RAD forms? I have two forms in my app, one using RAD and the other a normal fulcro form. It seems when I form/edit! after already using the other form for an entity, the form-state doesn’t get re-initialized and it doesn’t recognize my new form fields from the RAD form. Trying to figure out if theres an extra param i can pass to form/edit! to make sure its reset, or if i should explictly clear this state out somewhere else EDIT: Looks like the default state machine calls: (uism/apply-action fs/add-form-config* FormClass form-ident) which is not destructive by default, perhaps the fix is to just use my own state-machine? Or we could add a fo option to make this destructive?

tony.kay15:07:27

RAD should probably be forcing a re-initialization. There's no reason to preserve the form state in the RAD model.

Tyler Nisonoff15:07:26

:thumbsup: can submit a PR if you’d like

tony.kay16:07:54

Released

👍 2
genekim23:07:43

So delighted I got my first Fulcro program written that has state… Will write about what I struggled with and finally figured out soon! (Thinking I’m surely not the only person who got stuck on this!) But was surprised when I couldn’t find goog.string to use in CLJS portion. How does one access goog.string.format in a project based on Fulcro RAD template? Thx!

Tyler Nisonoff00:07:32

are you sure you can’t use it? I think Cursive may just not recognize it

tony.kay00:07:50

works for me

wilkerlucio00:07:26

the require format is invalid there, you have a vector of deps in place that you can only put one

3
wilkerlucio00:07:04

if we expand the reader macro, you will have something like: (:require [a] [b] [[c] [d]]) (note the [[c] [d]] is what the cljs reader macro will return)

genekim00:07:21

Doh. Thank you! Onwards! 🙂 :man-facepalming: (face-palm)

Jakub Holý (HolyJak)16:07:04

Remember difference between #?( and Tha splicing variant with @ in it (I don't remember, perhaps #?@( ?)