Fork me on GitHub
#reagent
<
2020-01-01
>
willier03:01:00

Hi, am trying to use the “react-select” component

"react-select": "^3.0.0"
in my re-frame app as follows:
(require '[reagent.core :as reagent])
(require '["react-select" :as Select])

(reagent/render [:div [:> Select {:options (clj->js [{:label "a" :value "A"}])}]]
                (.getElementById js/document "app"))
But getting error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

willier03:01:19

What am i getting wrong?

sogaiu03:01:30

as -> :as?

willier03:01:09

yea sorry typo in my message

sogaiu03:01:57

usually in cljs do you not want things in a ns form?

willier04:01:08

just trying to get it working from the REPL for now but was seeing the issue in my regular ns

sogaiu04:01:23

the repl experience in cljs varies a fair bit iirc - also i have not found it as dynamic. sorry if this isn't helping, but just mentioning some things that stumped me before.

sogaiu04:01:39

fwiw, if you are using shadow-cljs, there is a #shadow-cljs

willier04:01:48

yes, have been using shadow-cljs and it’s been pretty good

sogaiu04:01:02

yes, i agree

willier04:01:09

sure thanks - although i thought my issue might be with interop

sogaiu04:01:18

@willier there is something similar mentioned here: https://clojurians-log.clojureverse.org/reagent/2017-06-06 (look for some of your error message)

sogaiu04:01:48

your error has object while the linked discussion has undefined

sogaiu04:01:43

this trick may work: (:require ["react-select" :default react-select]) - i.e. default instead of as

👍 4
willier04:01:42

ooh, that did work!

willier04:01:55

or at least in the repl

willier04:01:35

awesome - that worked.. thanks @sogaiu

👍 4