Fork me on GitHub
Sandra Iskander18:04:34

i need help how to include and use react-datepicker in clojurescript project i got error saying the cljsjs is not supported and when i try to solve it i failed.. any idea any one please??


You're using shadow-cljs, right? If so, there are examples of how to include NPM packages in its documentation.

Sandra Iskander09:04:51

yes using shadow-cljs, i required the package as follows:

Sandra Iskander09:04:49

(:require [reagent.core :as r] ["react-datepicker" :as datePicker ] ) But i dont know how to use it.. i tried (defn date-picker [] [:div [datePicker]] )


If something doesn't work, just (js/console.log datePicker) and try to reason about what's wrong with the import.

Sandra Iskander10:04:38

okay, the import worked and i got the input field with the selected today's date but when i click on it, it doesnt show the calendar and nothing happens [:div [:> js/DatePicker {:selected (js/Date.)}]]


If I have a function to specify! IFn on an object:

(defn specify-invoke [x invoke-fn]
  (specify! x
      ([this a]
       (invoke-fn a))
      ([this a b]
       (invoke-fn a b))
;;A lot more arities 
      ([this a b c d e f g h i j k l m n o p q r s t]
       (invoke-fn a b c d e f g h i j k l m n o p q r s t))
      ([this a b c d e f g h i j k l m n o p q r s t rest]
       (invoke-fn a b c d e f g h i j k l m n o p q r s t rest)))))
And I do this for a lot of objects, such as every dom element on my page is this going to have a major code size/performance impact relative to extending a type to the protocol? Or is this the kind of thing that gets optimized/minimized by the compiler?


i think it should be fine, you can check the compiled output here:


the code footprint shouldn't be much, but there will be a few function instances created for each call to specify-invoke, so that would increase the memory footprint of the app, but like all perf issues, the answer is "it depends". what are the constraints and expected use cases etc.

👍 4