Fork me on GitHub
#clojurescript
<
2021-07-09
>
zendevil.eth07:07:11

does anyone know what causes some nodes in a dom tree to be “ignored”? I’m getting an error that has a list of ignored nodes: https://gist.github.com/zendevil/aef84352e934bb810efea77d4d8ee126

oxalorg (Mitesh)07:07:16

Can you also link the code which is causing this error?

zendevil.eth09:07:04

(deftest test-home
  (render (r/reactify-component [:div [:p "Something"]]))
  (.click fireEvent (.getByText screen "Something"))
  (is (= "Something" (.getByText screen "Something")))
  )
This is the react testing library api

zendevil.eth10:07:06

I have the following:

[:img
       {:on-click (fn [event]
                    (go
                      (<p! (.. @(rf/subscribe [:magic]) -oauth
                               (loginWithRedirect
                                 #js {:provider "facebook"
                                      :redirectURI
                                      (.. js/window -location -origin)})))))
        :src      ""
        :style    {:display :block :cursor :pointer :height 50 :max-height 50
                   :width   :auto
                   }}]
And I’m getting a warning (shadow-cljs):
70 |      [:div {:style {:height 50 :display :flex :flex-direction :row}}
  71 |       [:img
  72 |        {:on-click (fn [event]
  73 |                     (go
---------------------------^----------------------------------------------------
Cannot infer target type in expression (. inst_66948 -oauth)
--------------------------------------------------------------------------------
  74 |                       (<p! (.. @(rf/subscribe [:magic]) -oauth
  75 |                                (loginWithRedirect
  76 |                                  #js {:provider "facebook"
  77 |                                       :redirectURI
I tried ^object, but that still gives the warning. How to remove it?

p-himik10:07:11

Use ^js instead of ^object in front of @(rf/subscribe [:magic]).

thheller10:07:33

core.async loses type hints in go block so you can't really typehint here

p-himik10:07:32

But I guess -oauth could be extracted from the go block. And I would definitely do that, given that I have no clue how Reagent reactive context works in go blocks.

thheller10:07:52

yeah honestly this shouldn't even be a go block at all

thheller10:07:29

you are ignoring the return value anyways so just don't use go at all

p-himik10:07:48

Ah, of course, makes sense!

thheller10:07:00

and what is :magic? probably something you are not supposed to store in re-frame state?

zendevil.eth10:07:27

yeah, perhaps not because my login isn’t really working correctly.

thheller10:07:29

(let [^js magic @(rf/subscribe [:magic])]
  [:img
   {:on-click (fn [event]
                (.. magic -oauth
                    (loginWithRedirect
                      #js {:provider "facebook"
                           :redirectURI
                           (.. js/window -location -origin)})))
    :src ""
    :style {:display :block :cursor :pointer :height 50 :max-height 50
            :width :auto
            }}])

thheller10:07:46

you cannot use rf/subscribe in callbacks, must use it in the render itself

zendevil.eth10:07:06

magic is the following. This event called through a reitit controller:

(rf/reg-event-fx
  :init-login
  (fn [{:keys [db]} _]
    (prn "init login")
    (let [magic (Magic. "pk_live_E0A5A86F2EF4DE14"
                        (clj->js {:extensions [(OAuthExtension.)]}))]
      {:db            (assoc db :magic magic)
       :set-logged-in magic})))

zendevil.eth10:07:04

(rf/reg-fx
 :set-logged-in
 (fn [magic]
   (go (rf/dispatch [:set-logged-in'
                  (<p! (.. magic -user (isLoggedIn)))]))))

(rf/reg-event-db
  :set-logged-in'
  (fn [db [_ logged-in?]]
    (assoc db :logged-in? logged-in?)))

zendevil.eth10:07:20

But my logged-in? value is still false after the redirect

thheller10:07:42

sorry no clue what that is or supposed to be

zendevil.eth10:07:57

once in a blue moon it’s true but I don’t know why this isn’t consistent

thheller10:07:00

async code can be tough to get right if you don't know whats going on

zendevil.eth10:07:45

I’m kind of replicating this pure js code: https://codesandbox.io/s/2d9jo?file=/index.html

thheller10:07:48

there is no isLoggedIn in that code?

zendevil.eth10:07:02

Yeah I’m building on top of it now from this api: https://magic.link/docs/client-sdk/web/api-reference

thheller10:07:55

sorry no time for this

leif20:07:20

Is there a function that performs the name wrangling that the clojurescript compiler does with identifiers?

leif20:07:51

(At least on the basic optimization settings or lower. Obviously at higher levels its trickier... 😉 )

leif20:07:19

So far, the best I've got is to try to call compile-str , which seems like overkill.

leif21:07:42

Ah, nvm. You call it munge here. 🙂

emccue21:07:48

Super curious what research/project you are doing with clojurescript

emccue21:07:47

I only met you extremely briefly like 5 years ago when I was a freshman, but iirc at that time you or someone else in the dept was working on whalesong

leif22:07:09

And currently trying to make it in clojurescript.

emccue22:07:56

This might be a dumb suggestion considering i've only seen 10 seconds so far - but it might be easier to integrate with sci

leif01:07:20

Yes, it would. The only reason I didn't was because its harder to get sci to work with stopify, which I'm using to not lock up the UI.

leif01:07:36

(I could run all of sci in stopify, but that's quite slow.)

leif01:07:52

Using cljs.js allows me to directly compile to js.

leif01:07:34

(Which then get's further compiled by stopify+polyfills...but that's another story. 😉