Fork me on GitHub
#rum
<
2018-06-06
>
Matt Butler12:06:38

Is there a reason that rum doesnt expose a create-component in its public api, basically defc without 5.

1. Wraps body into sablono/compile-html
     2. Generates render function from that
     3. Takes render function and mixins, builds React class from them
     4. Using that class, generates constructor fn [args]->ReactElement
     5. Defines top-level var with provided name and assigns ctor to it
For purposes of wrapping a component in an arbitrary fn.

Niki15:06:32

I don’t understand. What can you do with component but to instantiate it?

Matt Butler15:06:29

My imagined use case is needing to wrap a component so that it has closure over some vars etc.

(defn wrapped-component [x]
  (create-component {:render [:div x] :will-update #(... x ...))}
Without having to to use defcs and inspect the args to fetch out something for example.

Matt Butler15:06:34

Maybe this isnt a distinct use case, I'm not claiming to be right, I would just expect to be able to define my own function that returns a component.

Niki18:06:00

well your function can just call rum function, can’t it?