Fork me on GitHub
#clojurescript
<
2020-11-05
>
gekkou04:11:58

Hello all, very new to clj and cljs. have been trying to get a good cljs environment set up in vscode using calva, but cant seem to connect to a repl. I want to be able to create small scripts using cljs, so want to target node and be able to use npm packages. I have figured out how to interact with npm packages and how to compile the code, but cant seem to get a good environment set up

kidpollo04:11:55

maybe also try #vscode

pez06:11:47

shadow-cljs and Calva are friends. Of that's not an option I think Clover might work.

gekkou04:11:39

if anyone has went through this process before and can help, all the help is much appreciated

Joe13:11:18

Hello, does anyone have any experience with trying to write Office addins using the https://docs.microsoft.com/en-us/office/dev/add-ins/reference/javascript-api-for-office in Clojurescript?

Chris McCormick13:11:08

i used wisp to write an office add-in so i may be able to help depending on what the issue is (wisp is not clojurescript but is clojure-like and shares some similarities)

Chris McCormick13:11:53

the office api makes heavy use of promises so i imagine the new <p! from core.async would come in very handy

johanatan18:11:55

does anybody understand how the following deftest (defined in a .clj file) is being run in this example project? the readme is woefully incomplete on this aspect of it. https://github.com/oliyh/kamera/blob/master/example/test/example/kamera_test.clj#L5

johanatan18:11:35

I tried following this setup and my cljs test environment (w/ figwheel main & tools.deps) just ignores that file/test

thheller19:11:53

@johanatan my guess would be lein test?

johanatan19:11:51

@thheller yep, that’s my guess as well. But does this run both the cljs tests and the clj one?

johanatan19:11:37

In my case I already have a bunch of deftests that are running in the CLJS context

thheller19:11:38

looks like CLJ is driving the CLJS tests in this case?

thheller19:11:54

I mean isn't that was the library is about?

johanatan19:11:26

Not entirely no. This library does what it does. It doesn’t “drive” all of your “CLJS tests”

johanatan19:11:22

@thheller that drives the devcards tests yes

johanatan19:11:01

The question is about how to integrate that into an existing CLJS test infrastructure

thheller19:11:56

I might be missing the point of the library but it looks to me like that IS the test infrastructure. you define devcards, it takes screenshots and compares results.

johanatan19:11:21

That is one aspect of a testing infrastructure

johanatan19:11:24

It is not the totality

Andrei Stan19:11:43

hi, i`m trying to set-up react-dropzone, but without success; can someone point me in the right direction with this one ? https://react-dropzone.js.org/ :

import React from 'react'
import Dropzone from 'react-dropzone'

<Dropzone onDrop={acceptedFiles => console.log(acceptedFiles)}>
  {({getRootProps, getInputProps}) => (
    <section>
      <div {...getRootProps()}>
        <input {...getInputProps()} />
        <p>Drag 'n' drop some files here, or click to select files</p>
      </div>
    </section>
  )}
</Dropzone>
my code in clojurescript:
(defn MyDropzone [] (let [onDrop (react/useCallback (fn [acceptedFiles] (js/console.log acceptedFiles))) props (useDropzone (clj->js {"onDrop" onDrop})) get-root-props (.-getRootProps props) get-input-props (.-getInputProps props)] [:> react/Dropzone [get-root-props get-input-props] {:on-drop #(js/console.log (-> %))} [:section [:div (get-root-props) [:input (get-input-props)] [:p "Drag n' drop some files here"]]]]))
errors:
main.js:1673 Invariant Violation: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See  for tips about how to debug and fix this problem.
    at invariant ()
    at Object.throwInvalidHookError ()
    at Object.useCallback ()
    at cmp.netdava$homebank$app$converter$MyDropzone [as reagentRender] ()
    at eval ()
    at Object.reagent$impl$component$wrap_render [as wrap_render] ()
    at Object.reagent$impl$component$do_render [as do_render] ()
    at eval ()
    at Object.reagent$ratom$in_context [as in_context] ()
    at Object.reagent$ratom$deref_capture [as deref_capture] ()

p-himik19:11:25

react/Dropzone doesn't look like react-dropzone/Dropzone. By default, Reagent generates class components. More details on how to overcome this are here and in the next section: https://github.com/reagent-project/reagent/blob/master/doc/ReactFeatures.md#function-components

johanatan19:11:05

“run-tests-async” runs CLJS tests

thheller19:11:30

@johanatan I don't have a clue. you asked how the deftest would be run and it looks like lein test. I don't know anything about the rest.

thheller19:11:20

I suppose the test.cljs.edn and figwheel come into play somehow

johanatan19:11:07

Yes I asked that because the normal way this works is for the one I linked to run. Therefore there is a question about what mechanism precisely allows both varieties of these tests to work. Particularly the “abnormal” one.

johanatan19:11:17

It is a valid question whether you see it or accept it or not.

johanatan19:11:04

If you “don’t know anything about the rest” then perhaps waiting for someone who does to chime in would be a good tack?

thheller19:11:05

ok, goodbye. sorry I tried answering your initial question.

johanatan19:11:19

No worries. I appreciate the attempt

Karol Wójcik20:11:56

That was rude!

👍 6
johanatan23:11:34

i've found the answer: I need a separate (pure Clojure) "main" and to manually call "clojure.test/run-all-tests" (which leiningen is automagically doing).