Fork me on GitHub
#reagent
<
2017-12-02
>
raheel18:12:39

I am trying to reproduce the foreign-libs + webpack setup here http://blob.tomerweller.com/reagent-import-react-components-from-npm, but with the latest versions of all deps. My rendering function looks like this:

(defn home-page []
(let [react-player (aget js/window "deps" "react-player")]
[:div
[:h2 "Welcome to Reagent"]
[:> react-player {:url ""}]
]))
However, I am getting this error…
Error: Assert failed: Expected React component in: [:> #js {:default #object[t]} {:url ""}]
(in mystyle.core.home_page)
(or (string? comp) (fn? comp))

mikerod22:12:24

@raheel well, it is considered bad practice to use aget for js field access like that. See https://clojurescript.org/news/2017-07-14-checked-array-access

mikerod22:12:30

Not that I think that is your issue

mikerod22:12:14

(:require [goog.obj :as gobj]) (gobj/getValueByKeys js/window "deps" "react-player")

mikerod22:12:51

I don’t believe I see the problem otherwise;

raheel22:12:24

hmm. Yeah guess I am trying to figure out the error message. I believe that the Webpack part of dependency injection is working fine. And it’s my usage in the hiccup that’s off.

raheel22:12:09

thanks for the aget usage pointer