This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-24
Channels
- # announcements (1)
- # beginners (113)
- # calva (16)
- # cider (6)
- # cljsrn (1)
- # clojure (104)
- # clojure-argentina (2)
- # clojure-dev (3)
- # clojure-italy (1)
- # clojure-nl (10)
- # clojure-spec (6)
- # clojure-uk (4)
- # clojuredesign-podcast (44)
- # clojurescript (25)
- # core-async (2)
- # datomic (21)
- # emacs (14)
- # events (1)
- # figwheel-main (12)
- # fulcro (7)
- # joker (2)
- # leiningen (1)
- # mount (7)
- # music (1)
- # off-topic (16)
- # pedestal (3)
- # re-frame (8)
- # reagent (8)
- # reitit (11)
- # shadow-cljs (4)
- # spacemacs (16)
- # sql (1)
- # tools-deps (14)
- # vim (1)
@neo2551 I've never used the context API but it looks like this might address it: https://github.com/Lokeh/reagent-context
I will try. My issue is there are some mutability in the JavaScript package that are not reflected in reagent. But let’s see
does anybody have a suggestion for an autocomplete component (input, with autocomplete functionality)?
https://ant.design/components/auto-complete/ is what I’ll often use
Can also go with https://material-ui.com/components/autocomplete/
If you’re not all that familiar with webpack you can go with re-com although I’ve found it to be a little glitchy sometimes but it’s the easiest to incorporate
I'd start with html5 datalist and see how far you can get with it.
(defonce app-state (atom {}))
(defn autocomplete [{:keys [items on-change]}]
[:<>
[:input {:type "text" :list "id-123" :on-change on-change}]
[:datalist {:id "id-123"}
(for [item items]
[:option {:key item :value item}])]])
(defn hello-world []
[:div
[:h1 "Datalist demo"]
[autocomplete
{:items ["cat" "dog" "sheep" "chicken" "whale"]
:on-change #(swap! app-state assoc :selected-item (-> % .-target .-value))}]
[:h3 (str "Selected item: " (or (:selected-item @app-state) "-"))]])
If this is not enough then you should look into react-select
, react-autosuggest
or downshift
components. They offer bunch of functionality but the downside is that they're quite complex.