Skip to content

Instantly share code, notes, and snippets.

@apostolou
Last active June 5, 2019 13:03
Show Gist options
  • Save apostolou/32781ac4dd4f6906ca7229ce2c5e30c8 to your computer and use it in GitHub Desktop.
Save apostolou/32781ac4dd4f6906ca7229ce2c5e30c8 to your computer and use it in GitHub Desktop.
example of usage of cljsjs.react-select
(ns react-select.core
(:require [re-frame.core :as re-frame]
[reagent.core :as r]
[cljsjs.react-select]))
(def payment-modes ["Amex" "Visa" "Cash" "Paypal"])
(def payment-options
(mapv zipmap (repeat [:label :value]) (mapv vector payment-modes (range 10))))
(def selected-values (r/atom nil))
(defn react-select
[placeholder options val]
[:> js/Select
{:isMulti true
:options options
:placeholder placeholder
:value @val
:on-change #(reset! val (js->clj % :keywordize-keys true))}])
(defn component []
[react-select "Payment mode" payment-options selected-values])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment