Fork me on GitHub

Hi all. I found this behavior odd. re-matches behaves differently in CLJS than in Clojure. Below is Clojure.

(re-matches #"/subscriptions/(.*?)" "/subscriptions/foo")
=> ["/subscriptions/foo" "foo"]
(re-find #"/subscriptions/(.*?)" "/subscriptions/foo")
=> ["/subscriptions/" ""]
(re-matches #"/subscriptions/(.*?)" "/subscriptions/foo")
=> nil
(re-find #"/subscriptions/(.*?)" "/subscriptions/foo")
=> ["/subscriptions/" ""]
Removing the ? in the regex makes the regex return the same result as in Clojure. I assume this is simply Java re vs JS re engines?


If your goal is cross platform regex then you might consider looking at

Alex Miller (Clojure team)01:02:02

generally, regexes will not be identical across the two hosts

matt sporleder02:02:09

the ? does nothing in that case because it isn't followed by anything, I think

matt sporleder02:02:33

I think it's a bug?

matt sporleder02:02:56

in javascript:

Array [ "/subscriptions/", "" ]

matt sporleder02:02:21

but also js definitely treats non-greedy operators weirdly

matt sporleder02:02:17

@kenny anchor it (`(re-matches #"\/subscriptions\/(.*?)$" "/subscriptions/foo")` ) for sanity I think


I have to deal with some deeply nested objects passed to me from a React library. But optimization mangles my keys so that

(.. info -event -_def -extendedProps -deletable)
get compiled as
The b part is fine but the Ui key does not exist on the extendedProps object - it should be deletable. Is there a way to tell Closure/CLJS not to mangle this line? Or a suggested workaround?


I figured out this workaround:

(aget (.. info -event -_def -extendedProps) "deletable")
This works since Closure preserves string literals. I'd still be interested to hear other folks' advice around this, though.


Don't use aget - it's for arrays. Try prefixing info with ^js:

(.. ^js info -event -_def -extendedProps -deletable)


That works! Thanks!


Got a link handy where I can read more about what ^js actually does? One of those things that's hard to google 🙂


The first thheller's link doesn't mention ^js though. The second one does.


^js works just fine in CLJS as well. as will the js/Foo in shadow-cljs. the second post explains why its not the recommended way in shadow-cljs.


Another alternative is to not use interop calls but use strings/keywords like this: (get-in-obj info [:event :_def :extendedProps :deletable]) With this option, you don’t need to worry about externs. (but I also like in many cases to use the (.. ) interop)


Thanks all, I have some reading to do! :)


Never really understood externs before (never really had to) but this made it click.


Hi, does anybody know a cljs-lib for reading and writing yaml ?


I’m using the library

["react-hook-form" :refer [useForm]]
And I’m using useForm like so:
(defn sign-up-form []
  (let [form (useForm)
    [:div (tw ["w-9/12"])
     [:div (tw [:text-lg :font-bold]) "Sign Up and Pay For Plan"]
      (tw style/text-input
          [:border-none :outline-none]
          {:placeholder "Name"})]
      (tw style/text-input
          [:border-none :outline-none]
          {:placeholder "Phone Number"})]

      (tw style/text-input
          [:border-none :outline-none]
          {:placeholder "Email"})]
      (tw style/text-input
          [:border-none :outline-none]
          {:placeholder "Password"
           :type :password})]
      (tw style/text-input
          [:border-none :outline-none]
          {:placeholder "Confirm Password"
           :type :password})]
     [:> Elements {:stripe stripe-promise}
     [:button (tw style/button [:bg-green-700 :text-white]) "Sign Up and Pay"]]))
However, the page refuses to load, and I’m getting the following error: Uncaught ReferenceError: $jscomp is not defined at Object.exports.useForm (:3000/js/cljs-runtime/module$node_modules$react_hook_form$dist$index_cjs_development.js:86) at Function.vendo$signup$sign_up_form (:3000/js/cljs-runtime/vendo.signup.js:63) at Function.eval [as cljs$core$IFn$_invoke$arity$2] (:3000/js/cljs-runtime/cljs.core.js:13256) at Function.eval [as cljs$core$IFn$_invoke$arity$2] (:3000/js/cljs-runtime/cljs.core.js:13541) at Object.reagent$impl$component$functional_wrap_render [as functional_wrap_render] (:3000/js/cljs-runtime/reagent.impl.component.js:625) at Object.reagent$impl$component$functional_do_render [as functional_do_render] (:3000/js/cljs-runtime/reagent.impl.component.js:674) at eval (:3000/js/cljs-runtime/reagent.impl.component.js:730) at Object.reagent$ratom$in_context [as in_context] (:3000/js/cljs-runtime/reagent.ratom.js:66) at Object.reagent$ratom$deref_capture [as deref_capture] (:3000/js/cljs-runtime/reagent.ratom.js:83) at Object.reagent$ratom$run_in_reaction [as run_in_reaction] (:3000/js/cljs-runtime/reagent.ratom.js:1508) how to fix this error?


Hey guys I have the following component

(defsc AccountListItem
  "An account list item"
  [this {:account/keys [id name email active? edit] :as props}]
  {:query [:account/id :account/name :account/email :account/active?
           {:account/edit ['*]}]
   :ident :account/id
   :initLocalState (fn [this _] {:editing? false})}
  (let [editing? (prim/get-state this :editing?)]
    (if editing?
      (account-form props)
       (dom/td name)
       (dom/td email)
                 (if active? "Active" "Inactive")))
        (dom/button {:onClick
                     (fn []
                         {:editing? (not editing?)})
                        (prim/transact! this `[(app.model.account/use-account-as-form {:account-id ~id})]))}
I'm trying to get rid of the editing? local state by having a :account/edit state on the root which will change when the edit button is pressed. However, when I try to retrieve the value of :account/edit on my query I get nil.


My Root query looks like the following:

                             #:account{:edit [*]}]}]}]}]


That defsc makes it seem like you're using Fulcro. If that's the case, it might be better to ask this in #fulcro


ah sorry I thoguht I was in fulcro channel, sorry about that