Closed lilactown closed 3 years ago
Are you talking about what the macro expands to, rather than the expected behaviour?
I think that's the normal Clojure behaviour?
user=> (defn hof [f] (fn [& args] (println "hof") (apply f args)))
#'user/hof
user=> (def foo (-> (fn foo [x] (if (zero? x) x (foo (dec x)))) hof))
#'user/foo
user=> (foo 3)
hof
0
hof
is called once on the layer (The literal (foo 3)
), but not on the nested calls.
the snippet in the OP is an example of what the macro expands to in order to remind me why this is happening.
the actual example macro call is:
(defnc node-view
[props]
{:wrap [(helix.core/memo)]}
($ node-view ,,,))
and I think it's surprising that the nested node-view
won't be wrapped in the helix.core/memo
HOC.
Since we create the inner fn of the component with the same name as var we are
def
ing, if you wrap the component in an HOC and call it recursively you end up getting the unwrapped component 😓example psuedo-code of the bug: