Fork me on GitHub

i ran into a situation where i’d like to have a component parameterize functionality in react lifecycle methods. basically i want a wrapper component for a bunch of different quil sketches, and i’d like to do something like (sketch-wrapper <sketch>), where the component will size itself, etc from the sketch parameters. the thing is i need to be able to call the particular sketch start function during :did-mount. normally in rum i’d use a mixin:

(defc sketch-wrapper < {:did-mount sketch-start-fn}
  [{:keys [sketch-start-fn]}]
but that doesn’t work here because the component arguments aren’t available when defining the mixin this way. in reagent i could do something like:
(defn sketch-wrapper [{:keys [sketch-start-fn]}]
    {:component-did-mount sketch-start-fn
is there a way to do something like this in rum?



(defc sketch-wrapper < 
  { :did-mount 
    (fn [state]
      (let [args (:rum/args state)
            [arg] args
            {:keys [sketch-start-fn]} arg]
        (sketch-start-fn))) }
  [{:keys [sketch-start-fn]}]


ah - great, thx!