A form-2 is just a form 3 where it's (defn foo [] (component-did-mount-fn) reagent-render-fn) right?
> weird... did it change from did to will in some version?
I did not mean it as a lifecycle method.
It's just that (component-did-mount-fn) in your code above will actually be called before the component is mounted. Because, well, in order for something to be mounted, you have to create that something. And when foo is called (when (component-did-mount-fn) is executed), that something is just being created.
As in a form-2 is a more restricted then a form-3
s/did/will and it'll become true, AFAIK.
Yeah, form-2 is more restricted and also more succinct.
Just in case - there's also r/with-let. Allows you to have a form-2-like component but with form-1 syntax and with an ability to run some code when the component is unmounted.
Yep, i'm aware (though only recently lol).
@p-himik weird... did it change from did to will in some version? our app says "will" as do the docs here: https://github.com/reagent-project/reagent/blob/master/doc/CreatingReagentComponents.md#form-3-a-class-with-life-cycle-methods
or wait, are those are different lifescycle methods...
oh it's component-will-unmount and component-did-mount (i guess it helps you orient the time around the render?)
is this https://github.com/reagent-project/reagent/blob/master/doc/CreatingReagentComponents.md#appendix-b---with-let-macro?
It says
> The with-let macro looks just like let – but the bindings only execute once, and it takes an optional finally clause, that runs when the component is no longer rendered. This can be particularly useful because it can prevent the need for a form-2 component in many instances (like creating a local reagent atom in your component)
Did it mean "form-3" where it said "form-2"?
I guess it wouldn't, but it's wording is confusing, because it says "like creating local reagent atom in your component" doens't a form let you do that anyway? I feel like it should say "when you need to clean up some state created by the component" which a form-2, to my knowledge has no place for.
i guess it also handled component-did-mount... https://cleancoders.com/blog/2025-02-01-goodbye-reagent-class-components-using-reagents-with-let-macro