This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-23
Channels
- # announcements (1)
- # babashka (68)
- # babashka-sci-dev (12)
- # beginners (36)
- # biff (22)
- # calva (20)
- # clerk (1)
- # clj-on-windows (7)
- # clojure (27)
- # clojure-conj (8)
- # clojure-denmark (2)
- # clojure-europe (141)
- # clojure-france (1)
- # clojure-italy (4)
- # clojure-nl (1)
- # clojure-uk (2)
- # clojurescript (7)
- # conjure (8)
- # core-async (111)
- # cursive (3)
- # datahike (4)
- # datalevin (18)
- # events (9)
- # gratitude (4)
- # guix (2)
- # helix (3)
- # hyperfiddle (62)
- # introduce-yourself (2)
- # kaocha (4)
- # london-clojurians (3)
- # lsp (7)
- # malli (34)
- # membrane (1)
- # nbb (9)
- # polylith (4)
- # portal (6)
- # reagent (4)
- # releases (2)
- # remote-jobs (4)
- # shadow-cljs (30)
- # sql (2)
- # tools-deps (58)
- # xtdb (9)
I’m trying to use @date-io/moment
package with material UI v4 time picker.
(ns cljs-material-ui.core
(:require [react :as React]
["@material-ui/core" :as MaterialUI]
["@material-ui/pickers" :as MUIPickers]
["@date-io/moment" :as DateIOMoment]))
(def moment-utils (aget DateIOMoment "MomentUtils"))
but moment-utils
is always nil
. I need to pass it as MuiPickersUtilsProvider
component utils
prop as per https://stackoverflow.com/a/59954779essentially I need to translate
import MomentUtils from "@date-io/moment";
<MuiPickersUtilsProvider utils={MomentUtils}>
into cljsAre you using a CJS or ESM distribution? I'll assume ESM for now, which in case you'll need to (require '["@date-io/moment$default" :as MomentUtils])
Assuming the utils
prop accepts a function, then you should be able to use MomentUtils
directly
Also, don't use aget
with strings - it's intended only for arrays.
When you need to get a field from a JS object that didn't come from goog.*
, just use externs inference and interop: (.-someField ^js obj)
(and ^js
is not even necessary a lot of the times).
see all the examples translating import to CLJS require https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages