Last active
June 5, 2019 13:03
-
-
Save apostolou/32781ac4dd4f6906ca7229ce2c5e30c8 to your computer and use it in GitHub Desktop.
example of usage of cljsjs.react-select
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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