Fork me on GitHub
#clojurescript
<
2020-04-06
>
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??

p-himik08:04:00

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]] )

p-himik09:04:48

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.)}]]

jjttjj18:04:24

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

(defn specify-invoke [x invoke-fn]
  (specify! x
    IFn
    (-invoke
      ([this]
       (invoke-fn))
      ([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?

dvingo20:04:55

i think it should be fine, you can check the compiled output here: http://app.klipse.tech/?js_only=1

dvingo20:04:28

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