clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
zhuxun2 2020-11-10T07:52:03.110Z

Is there a way to know if a value if a function or not?

zhuxun2 2020-11-10T07:52:38.110500Z

(type #()) gives #object[Function]

zhuxun2 2020-11-10T07:54:17.111800Z

is (= (type f) (type #())) the idiomatic way of determining it?

zhuxun2 2020-11-10T07:55:16.112500Z

Seems rather expensive needing to create a temp function

lassemaatta 2020-11-10T07:56:41.112900Z

have you tried the fn? predicate? (https://cljs.github.io/api/cljs.core/#fnQMARK)

👍 1
lassemaatta 2020-11-10T08:06:46.113100Z

also note the presence of ifn?, which returns true for anything that can be invoked like a function (e.g. many datastructures or keywords), not just actual functions

2020-11-10T09:03:07.116400Z

Have just started clojurescript with very basic setups, just to get the syntax. I am using Atom as text editor. Just wanted to ask what's the best setup as a beginner to get hands on clojurescript. I see many options if searched online and get confused. text editors emacs, vim, visual studio, atom. and what is basically fig-wheel, is it necessary right away at beginning!

paulbutcher 2020-11-10T09:41:43.116900Z

I would appreciate help debugging a js interop issue I’m having. I’m clearly misunderstanding something pretty basic. I am using the https://vega.github.io/vega/ library within my app. I’m compiling with Figwheel Main with NPM via :auto-bundle. Everything works just fine in dev, but I get an error in my production build when calling Vega methods. Vega is in my package.json and I’m importing it into my ClojureScript source with: [vega :refer [parse View]] . The code that causes the problem is:

(let [view (View. (parse (clj->js spec)) #js {:container (dom-node this)})]
        (.runAsync view)))
Creating a View object and calling the parse function both work fine, but when I try to call the runAsync method on the view, I get an error suggesting that advanced optimisations have chosen to rename it. Everything works just fine if I switch the last line to:
(js-invoke view "runAsync")))
Clearly I’m missing something I should be doing to tell the Closure compiler to leave the name of runAsync alone, but I’ve no idea what that might be?

borkdude 2020-11-10T10:50:17.118100Z

Btw, the spec issue I was having above wasn't solved after all. @lilactown fwiw, the specs were in the same namespace, so it's unlikely that this is a namespace ordering problem

😵 1
p-himik 2020-11-10T10:56:25.118200Z

Use (.runAsync ^js view).

paulbutcher 2020-11-10T11:02:02.119100Z

Ah! Thank you - I knew I had to be missing something basic!

Andrei Stan 2020-11-10T11:22:43.119800Z

hi, how can i write this into clojurescript?

{({getRootProps, getInputProps}) => (
    <section>
      <div {...getRootProps()}>
        <input {...getInputProps()} />
        <p>Drag 'n' drop some files here, or click to select files</p>
      </div>
    </section>
  )}

thheller 2020-11-10T12:19:57.120300Z

using what? reagent?

Andrei Stan 2020-11-10T12:20:45.121100Z

yes, sorry, Reagent

thheller 2020-11-10T12:21:25.121900Z

roughly translated its a function definition that destructures an object argument. we can't do that in CLJS but (fn [^js arg] [:section [:div (.getRootProps arg) ...]]) should do it

rberger 2020-12-08T21:49:30.201200Z

I got a first pass (a rough direct translation from react/JS to reagent/cljs) of React Beautiful Drag and Drop working in https://github.com/omnyway-labs/simple-list-dnd

Andrei Stan 2020-11-10T12:26:31.122100Z

i`m trying to implement react-dropzone https://react-dropzone.js.org/: what i want to translate into cjls with reagent:

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:
[:> Dropzone {} (fn [^js arg] [:section [:div (.getRootProps arg) ...]])]
if i console.log Dropzone i receive
{$$typeof: Symbol(react.forward_ref), displayName: "Dropzone", defaultProps: {…}, propTypes: {…}, render: ƒ}
Errors:

Andrei Stan 2020-11-10T12:26:31.122300Z

216 |      [convert-btn app-state]
 217 |      [:> Dropzone {} (fn [^js arg] [:section [:div (.getRootProps arg) ...]])]
----------------------------^---------------------------------------------------
null
IllegalArgumentException: no conversion to symbol
	clojure.core/symbol (core.clj:596)
	clojure.core/symbol (core.clj:589)
	cljs.analyzer/confirm-var-exists (analyzer.cljc:860)
	cljs.analyzer/confirm-var-exists (analyzer.cljc:848)
	cljs.analyzer/confirm-var-exists (analyzer.cljc:851)
	cljs.analyzer/confirm-var-exists (analyzer.cljc:848)
	shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:370)
	shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:148)
	cljs.analyzer/resolve-existing-var (analyzer.cljc:1298)
	cljs.analyzer/resolve-existing-var (analyzer.cljc:1293)
	cljs.analyzer/analyze-symbol (analyzer.cljc:3795)
	cljs.analyzer/analyze-symbol (analyzer.cljc:3759)
	cljs.analyzer/analyze-form (analyzer.cljc:4189)
	cljs.analyzer/analyze-form (analyzer.cljc:4187)
	cljs.analyzer/analyze* (analyzer.cljc:4243)
	cljs.analyzer/analyze* (analyzer.cljc:4235)
	cljs.analyzer/analyze (analyzer.cljc:4263)
	cljs.analyzer/analyze (analyzer.cljc:4246)
	cljs.analyzer/analyze (analyzer.cljc:4256)
	cljs.analyzer/analyze (analyzer.cljc:4246)
	cljs.analyzer/analyze (analyzer.cljc:4254)
	cljs.analyzer/analyze (analyzer.cljc:4246)
	cljs.analyzer/analyze-vector/fn--2648/fn--2649 (analyzer.cljc:4027)
	clojure.core/mapv/fn--8445 (core.clj:6912)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6827)
	clojure.core/mapv (core.clj:6903)
	clojure.core/mapv (core.clj:6903)
	cljs.analyzer/analyze-vector/fn--2648 (analyzer.cljc:4027)
	cljs.analyzer/analyze-vector (analyzer.cljc:4027)
	cljs.analyzer/analyze-vector (analyzer.cljc:4024)
	cljs.analyzer/analyze-form (analyzer.cljc:4193)
	cljs.analyzer/analyze-form (analyzer.cljc:4187)
	cljs.analyzer/analyze* (analyzer.cljc:4243)
	cljs.analyzer/analyze* (analyzer.cljc:4235)
	cljs.analyzer/analyze (analyzer.cljc:4263)
	cljs.analyzer/analyze (analyzer.cljc:4246)
	cljs.analyzer/analyze (analyzer.cljc:4256)
	cljs.analyzer/analyze (analyzer.cljc:4246)
	cljs.analyzer/analyze (analyzer.cljc:4254)
	cljs.analyzer/analyze (analyzer.cljc:4246)
	cljs.analyzer/analyze-vector/fn--2648/fn--2649 (analyzer.cljc:4027)
	clojure.core/mapv/fn--8445 (core.clj:6912)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6827)
	clojure.core/mapv (core.clj:6903)
	clojure.core/mapv (core.clj:6903)
	cljs.analyzer/analyze-vector/fn--2648 (analyzer.cljc:4027)
	cljs.analyzer/analyze-vector (analyzer.cljc:4027)
	cljs.analyzer/analyze-vector (analyzer.cljc:4024)
	cljs.analyzer/analyze-form (analyzer.cljc:4193)
	cljs.analyzer/analyze-form (analyzer.cljc:4187)
	cljs.analyzer/analyze* (analyzer.cljc:4243)
	cljs.analyzer/analyze* (analyzer.cljc:4235)
	cljs.analyzer/analyze (analyzer.cljc:4263)
	cljs.analyzer/analyze (analyzer.cljc:4246)
	cljs.analyzer/analyze (analyzer.cljc:4256)
	cljs.analyzer/analyze (analyzer.cljc:4246)
	cljs.analyzer/analyze (analyzer.cljc:4254)
	cljs.analyzer/analyze (analyzer.cljc:4246)
	cljs.analyzer/fn--2025 (analyzer.cljc:2276)
	cljs.analyzer/fn--2025 (analyzer.cljc:2272)
	clojure.lang.MultiFn.invoke (MultiFn.java:252)
	cljs.analyzer/analyze-seq* (analyzer.cljc:3974)
	cljs.analyzer/analyze-seq* (analyzer.cljc:3972)
	cljs.analyzer/analyze-seq*-wrap (analyzer.cljc:3979)
	cljs.analyzer/analyze-seq*-wrap (analyzer.cljc:3977)
	cljs.analyzer/analyze-seq (analyzer.cljc:4003)
	cljs.analyzer/analyze-seq (analyzer.cljc:3981)
	cljs.analyzer/analyze-form (analyzer.cljc:4190)
	cljs.analyzer/analyze-form (analyzer.cljc:4187)
	cljs.analyzer/analyze* (analyzer.cljc:4243)
	cljs.analyzer/analyze* (analyzer.cljc:4235)
	cljs.analyzer/analyze (analyzer.cljc:4263)
	cljs.analyzer/analyze (analyzer.cljc:4246)
	cljs.analyzer/analyze (analyzer.cljc:4256)
	cljs.analyzer/analyze (analyzer.cljc:4246)
	cljs.analyzer/analyze (analyzer.cljc:4254)
	cljs.analyzer/analyze (analyzer.cljc:4246)
	cljs.analyzer/analyze-fn-method-body (analyzer.cljc:2065)

thheller 2020-11-10T12:27:19.122600Z

you left the ... in. need to translate the rest.

Andrei Stan 2020-11-10T12:30:18.122800Z

Code:

[:> Dropzone {} (fn [^js arg] [:section [:div (.getRootProps arg) [:input (.getInputProps arg)] [:p "drag'n drop"]]])]
Error:

Andrei Stan 2020-11-10T12:30:18.123Z

react-dom.development.js:17118 The above error occurred in the <Dropzone> component:
    in Dropzone (created by netdava.homebank.app.converter.converter)
    in div (created by netdava.homebank.app.converter.converter)
    in div (created by netdava.homebank.app.converter.converter)
    in netdava.homebank.app.converter.converter

Consider adding an error boundary to your tree to customize error handling behavior.
Visit <https://fb.me/react-error-boundaries> to learn more about error boundaries.
logCapturedError @ react-dom.development.js:17118
logError @ react-dom.development.js:17154
expirationTime.callback @ react-dom.development.js:18066
commitUpdateEffects @ react-dom.development.js:16434
commitUpdateQueue @ react-dom.development.js:16464
commitAllLifeCycles @ react-dom.development.js:17384
callCallback @ react-dom.development.js:150
invokeGuardedCallbackImpl @ react-dom.development.js:200
invokeGuardedCallback @ react-dom.development.js:257
commitRoot @ react-dom.development.js:18949
eval @ react-dom.development.js:20419
exports.unstable_runWithPriority @ scheduler.development.js:256
completeRoot @ react-dom.development.js:20418
performWorkOnRoot @ react-dom.development.js:20347
performWork @ react-dom.development.js:20255
requestWork @ react-dom.development.js:20229
scheduleWork @ react-dom.development.js:19912
updateContainerAtExpirationTime @ react-dom.development.js:20573
updateContainer @ react-dom.development.js:20658
ReactRoot.render @ react-dom.development.js:20954
eval @ react-dom.development.js:21091
unbatchedUpdates @ react-dom.development.js:20460
legacyRenderSubtreeIntoContainer @ react-dom.development.js:21087
render @ react-dom.development.js:21156
reagent$dom$render_comp @ dom.cljs:17
eval @ dom.cljs:41
eval @ dom.cljs:36
netdava$homebank$app$core$render @ core.cljs:26
netdava$homebank$app$core$main @ core.cljs:31
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:2485
Show 3 more frames
shadow.module.main.append.js:4 An error occurred when calling (netdava.homebank.app.core/main)
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:2485
main.js:1672 An error occurred when loading shadow.module.main.append.js
env.evalLoad @ main.js:1672
(anonymous) @ main.js:2485
main.js:1673 Invariant Violation: Objects are not valid as a React child (found: object with keys {ns, name, fqn, _hash, cljs$lang$protocol_mask$partition0$, cljs$lang$protocol_mask$partition1$}). If you meant to render a collection of children, use an array instead.
    in Dropzone (created by netdava.homebank.app.converter.converter)
    in div (created by netdava.homebank.app.converter.converter)
    in div (created by netdava.homebank.app.converter.converter)
    in netdava.homebank.app.converter.converter
    at invariant (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:1:441>)
    at throwOnInvalidObjectType (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:173:103>)
    at createChild (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:182:360>)
    at reconcileChildrenIterator (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:195:419>)
    at eval (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:203:513>)
    at reconcileChildren (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:244:169>)
    at updateForwardRef (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:246:397>)
    at beginWork (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:298:352>)
    at performUnitOfWork (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:434:394>)
    at workLoop (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:436:49>)

Andrei Stan 2020-11-10T12:30:18.123200Z

thheller 2020-11-10T12:31:51.123400Z

looks like you are passing a CLJS map when a JS object is expected?

thheller 2020-11-10T12:32:14.123600Z

maybe [:&gt; Dropzone #js {} ...] instead of just the {}

Andrei Stan 2020-11-10T12:33:51.123800Z

checkPropTypes.js:21 Warning: Failed prop type: Invalid prop `children` of type `array` supplied to `Dropzone`, expected `function`.
    in Dropzone (created by netdava.homebank.app.converter.converter)
    in netdava.homebank.app.converter.converter
printWarning @ checkPropTypes.js:21
checkPropTypes @ checkPropTypes.js:83
validatePropTypes @ react.development.js:1667
createElementWithValidation @ react.development.js:1756
reagent$impl$template$make_element @ template.cljs:425
reagent$impl$template$native_element @ template.cljs:334
reagent$impl$template$vec_to_elem @ template.cljs:366
reagent$impl$template$as_element @ template.cljs:385
eval @ template.cljs:427
eval @ core.cljs:5666
eval @ core.cljs:5666
eval @ core.cljs:5670
cljs$core$_kv_reduce @ core.cljs:713
cljs$core$reduce_kv @ core.cljs:2578
reagent$impl$template$make_element @ template.cljs:425
reagent$impl$template$native_element @ template.cljs:334
reagent$impl$template$vec_to_elem @ template.cljs:362
reagent$impl$template$as_element @ template.cljs:385
reagent$impl$template$make_element @ template.cljs:422
reagent$impl$template$native_element @ template.cljs:334
reagent$impl$template$vec_to_elem @ template.cljs:362
reagent$impl$template$as_element @ template.cljs:385
reagent$impl$template$make_element @ template.cljs:422
reagent$impl$template$fragment_element @ template.cljs:305
reagent$impl$template$vec_to_elem @ template.cljs:356
reagent$impl$template$as_element @ template.cljs:385
reagent$impl$component$wrap_render @ component.cljs:114
reagent$impl$component$do_render @ component.cljs:141
eval @ component.cljs:164
reagent$ratom$in_context @ ratom.cljs:42
reagent$ratom$deref_capture @ ratom.cljs:55
reagent$ratom$run_in_reaction @ ratom.cljs:537
reagent$impl$component$render @ component.cljs:164
finishClassComponent @ react-dom.development.js:14742
updateClassComponent @ react-dom.development.js:14697
beginWork @ react-dom.development.js:15645
performUnitOfWork @ react-dom.development.js:19313
workLoop @ react-dom.development.js:19353
renderRoot @ react-dom.development.js:19436
performWorkOnRoot @ react-dom.development.js:20343
performWork @ react-dom.development.js:20255
requestWork @ react-dom.development.js:20229
scheduleWork @ react-dom.development.js:19912
updateContainerAtExpirationTime @ react-dom.development.js:20573
updateContainer @ react-dom.development.js:20658
ReactRoot.render @ react-dom.development.js:20954
eval @ react-dom.development.js:21091
unbatchedUpdates @ react-dom.development.js:20460
legacyRenderSubtreeIntoContainer @ react-dom.development.js:21087
render @ react-dom.development.js:21156
reagent$dom$render_comp @ dom.cljs:17
eval @ dom.cljs:41
eval @ dom.cljs:36
netdava$homebank$app$core$render @ core.cljs:26
netdava$homebank$app$core$main @ core.cljs:31
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:2485
Show 29 more frames
index.js:2 Uncaught TypeError: n is not a function
    at eval (index.js:2)
    at renderWithHooks (react-dom.development.js:12939)
    at updateForwardRef (react-dom.development.js:14458)
    at beginWork (react-dom.development.js:15662)
    at performUnitOfWork (react-dom.development.js:19313)
    at workLoop (react-dom.development.js:19353)
    at HTMLUnknownElement.callCallback (react-dom.development.js:150)
    at Object.invokeGuardedCallbackImpl (react-dom.development.js:200)
    at invokeGuardedCallback (react-dom.development.js:257)
    at replayUnitOfWork (react-dom.development.js:18579)
eval @ index.js:2
renderWithHooks @ react-dom.development.js:12939
updateForwardRef @ react-dom.development.js:14458
beginWork @ react-dom.development.js:15662
performUnitOfWork @ react-dom.development.js:19313
workLoop @ react-dom.development.js:19353
callCallback @ react-dom.development.js:150
invokeGuardedCallbackImpl @ react-dom.development.js:200
invokeGuardedCallback @ react-dom.development.js:257
replayUnitOfWork @ react-dom.development.js:18579
renderRoot @ react-dom.development.js:19469
performWorkOnRoot @ react-dom.development.js:20343
performWork @ react-dom.development.js:20255
requestWork @ react-dom.development.js:20229
scheduleWork @ react-dom.development.js:19912
updateContainerAtExpirationTime @ react-dom.development.js:20573
updateContainer @ react-dom.development.js:20658
ReactRoot.render @ react-dom.development.js:20954
eval @ react-dom.development.js:21091
unbatchedUpdates @ react-dom.development.js:20460
legacyRenderSubtreeIntoContainer @ react-dom.development.js:21087
render @ react-dom.development.js:21156
reagent$dom$render_comp @ dom.cljs:17
eval @ dom.cljs:41
eval @ dom.cljs:36
netdava$homebank$app$core$render @ core.cljs:26
netdava$homebank$app$core$main @ core.cljs:31
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:2485
react-dom.development.js:17118 The above error occurred in the &lt;Dropzone&gt; component:
    in Dropzone (created by netdava.homebank.app.converter.converter)
    in div (created by netdava.homebank.app.converter.converter)
    in div (created by netdava.homebank.app.converter.converter)
    in netdava.homebank.app.converter.converter

Consider adding an error boundary to your tree to customize error handling behavior.
Visit <https://fb.me/react-error-boundaries> to learn more about error boundaries.
logCapturedError @ react-dom.development.js:17118
logError @ react-dom.development.js:17154
expirationTime.callback @ react-dom.development.js:18066
commitUpdateEffects @ react-dom.development.js:16434
commitUpdateQueue @ react-dom.development.js:16464
commitAllLifeCycles @ react-dom.development.js:17384
callCallback @ react-dom.development.js:150
invokeGuardedCallbackImpl @ react-dom.development.js:200
invokeGuardedCallback @ react-dom.development.js:257
commitRoot @ react-dom.development.js:18949
eval @ react-dom.development.js:20419
exports.unstable_runWithPriority @ scheduler.development.js:256
completeRoot @ react-dom.development.js:20418
performWorkOnRoot @ react-dom.development.js:20347
performWork @ react-dom.development.js:20255
requestWork @ react-dom.development.js:20229
scheduleWork @ react-dom.development.js:19912
updateContainerAtExpirationTime @ react-dom.development.js:20573
updateContainer @ react-dom.development.js:20658
ReactRoot.render @ react-dom.development.js:20954
eval @ react-dom.development.js:21091
unbatchedUpdates @ react-dom.development.js:20460
legacyRenderSubtreeIntoContainer @ react-dom.development.js:21087
render @ react-dom.development.js:21156
reagent$dom$render_comp @ dom.cljs:17
eval @ dom.cljs:41
eval @ dom.cljs:36
netdava$homebank$app$core$render @ core.cljs:26
netdava$homebank$app$core$main @ core.cljs:31
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:2485
Show 3 more frames
shadow.module.main.append.js:4 An error occurred when calling (netdava.homebank.app.core/main)
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:2485
main.js:1672 An error occurred when loading shadow.module.main.append.js
env.evalLoad @ main.js:1672
(anonymous) @ main.js:2485
main.js:1673 TypeError: n is not a function
    at eval (index.js:2)
    at renderWithHooks (react-dom.development.js:12939)
    at updateForwardRef (react-dom.development.js:14458)
    at beginWork (react-dom.development.js:15662)
    at performUnitOfWork (react-dom.development.js:19313)
    at workLoop (react-dom.development.js:19353)
    at renderRoot (react-dom.development.js:19436)
    at performWorkOnRoot (react-dom.development.js:20343)
    at performWork (react-dom.development.js:20255)
    at requestWork (react-dom.development.js:20229)

Andrei Stan 2020-11-10T12:33:51.124Z

thheller 2020-11-10T12:35:17.124200Z

it expected a function which you didn't provide? don't know what. maybe the onDrop?

thheller 2020-11-10T12:35:43.124400Z

or maybe its reagent messing up

thheller 2020-11-10T12:36:03.124600Z

you can try (react/createElement Dropzone nil (fn [^js arg] ...)) instead?

thheller 2020-11-10T12:37:38.124800Z

react being (:require ["react" :as react]) in the ns of course

Andrei Stan 2020-11-10T12:40:18.125Z

react-dom.development.js:56 Uncaught Invariant Violation: Objects are not valid as a React child (found: object with keys {ns, name, fqn, _hash, cljs$lang$protocol_mask$partition0$, cljs$lang$protocol_mask$partition1$}). If you meant to render a collection of children, use an array instead.
    in Dropzone (created by netdava.homebank.app.converter.converter)
    in div (created by netdava.homebank.app.converter.converter)
    in div (created by netdava.homebank.app.converter.converter)
    in netdava.homebank.app.converter.converter
    at invariant (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:1:441>)
    at throwOnInvalidObjectType (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:173:103>)
    at createChild (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:182:360>)
    at reconcileChildrenIterator (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:195:419>)
    at eval (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:203:513>)
    at reconcileChildren (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:244:169>)
    at updateForwardRef (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:246:397>)
    at beginWork (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:298:352>)
    at performUnitOfWork (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:434:394>)
    at workLoop (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:436:49>)
invariant @ react-dom.development.js:56
throwOnInvalidObjectType @ react-dom.development.js:11834
createChild @ react-dom.development.js:12045
reconcileChildrenIterator @ react-dom.development.js:12428
eval @ react-dom.development.js:12604
reconcileChildren @ react-dom.development.js:14403
updateForwardRef @ react-dom.development.js:14475
beginWork @ react-dom.development.js:15662
performUnitOfWork @ react-dom.development.js:19313
workLoop @ react-dom.development.js:19353
callCallback @ react-dom.development.js:150
invokeGuardedCallbackImpl @ react-dom.development.js:200
invokeGuardedCallback @ react-dom.development.js:257
replayUnitOfWork @ react-dom.development.js:18579
renderRoot @ react-dom.development.js:19469
performWorkOnRoot @ react-dom.development.js:20343
performWork @ react-dom.development.js:20255
requestWork @ react-dom.development.js:20229
scheduleWork @ react-dom.development.js:19912
updateContainerAtExpirationTime @ react-dom.development.js:20573
updateContainer @ react-dom.development.js:20658
ReactRoot.render @ react-dom.development.js:20954
eval @ react-dom.development.js:21091
unbatchedUpdates @ react-dom.development.js:20460
legacyRenderSubtreeIntoContainer @ react-dom.development.js:21087
render @ react-dom.development.js:21156
reagent$dom$render_comp @ dom.cljs:17
eval @ dom.cljs:41
eval @ dom.cljs:36
netdava$homebank$app$core$render @ core.cljs:26
netdava$homebank$app$core$main @ core.cljs:31
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:2485
Show 5 more frames
react-dom.development.js:17118 The above error occurred in the &lt;Dropzone&gt; component:
    in Dropzone (created by netdava.homebank.app.converter.converter)
    in div (created by netdava.homebank.app.converter.converter)
    in div (created by netdava.homebank.app.converter.converter)
    in netdava.homebank.app.converter.converter

Consider adding an error boundary to your tree to customize error handling behavior.
Visit <https://fb.me/react-error-boundaries> to learn more about error boundaries.
logCapturedError @ react-dom.development.js:17118
logError @ react-dom.development.js:17154
expirationTime.callback @ react-dom.development.js:18066
commitUpdateEffects @ react-dom.development.js:16434
commitUpdateQueue @ react-dom.development.js:16464
commitAllLifeCycles @ react-dom.development.js:17384
callCallback @ react-dom.development.js:150
invokeGuardedCallbackImpl @ react-dom.development.js:200
invokeGuardedCallback @ react-dom.development.js:257
commitRoot @ react-dom.development.js:18949
eval @ react-dom.development.js:20419
exports.unstable_runWithPriority @ scheduler.development.js:256
completeRoot @ react-dom.development.js:20418
performWorkOnRoot @ react-dom.development.js:20347
performWork @ react-dom.development.js:20255
requestWork @ react-dom.development.js:20229
scheduleWork @ react-dom.development.js:19912
updateContainerAtExpirationTime @ react-dom.development.js:20573
updateContainer @ react-dom.development.js:20658
ReactRoot.render @ react-dom.development.js:20954
eval @ react-dom.development.js:21091
unbatchedUpdates @ react-dom.development.js:20460
legacyRenderSubtreeIntoContainer @ react-dom.development.js:21087
render @ react-dom.development.js:21156
reagent$dom$render_comp @ dom.cljs:17
eval @ dom.cljs:41
eval @ dom.cljs:36
netdava$homebank$app$core$render @ core.cljs:26
netdava$homebank$app$core$main @ core.cljs:31
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:2485
Show 3 more frames
shadow.module.main.append.js:4 An error occurred when calling (netdava.homebank.app.core/main)
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:2485
main.js:1672 An error occurred when loading shadow.module.main.append.js
env.evalLoad @ main.js:1672
(anonymous) @ main.js:2485
main.js:1673 Invariant Violation: Objects are not valid as a React child (found: object with keys {ns, name, fqn, _hash, cljs$lang$protocol_mask$partition0$, cljs$lang$protocol_mask$partition1$}). If you meant to render a collection of children, use an array instead.
    in Dropzone (created by netdava.homebank.app.converter.converter)
    in div (created by netdava.homebank.app.converter.converter)
    in div (created by netdava.homebank.app.converter.converter)
    in netdava.homebank.app.converter.converter
    at invariant (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:1:441>)
    at throwOnInvalidObjectType (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:173:103>)
    at createChild (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:182:360>)
    at reconcileChildrenIterator (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:195:419>)
    at eval (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:203:513>)
    at reconcileChildren (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:244:169>)
    at updateForwardRef (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:246:397>)
    at beginWork (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:298:352>)
    at performUnitOfWork (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:434:394>)
    at workLoop (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:436:49>)
env.evalLoad @ main.js:1673
(anonymous) @ main.js:2485

Andrei Stan 2020-11-10T12:40:18.125200Z

Andrei Stan 2020-11-10T12:40:40.125400Z

i am using reagent 0.10.0

thheller 2020-11-10T12:41:11.125600Z

suppose it might be the return value of the function

thheller 2020-11-10T12:41:33.125800Z

so try (fn [arg] (reagent/as-element [:section ...]))

Andrei Stan 2020-11-10T12:43:10.126Z

react-dom.development.js:56 Uncaught Invariant Violation: Objects are not valid as a React child (found: object with keys {onKeyDown, onFocus, onBlur, onClick, onDragEnter, onDragOver, onDragLeave, onDrop, ref, tabIndex}). If you meant to render a collection of children, use an array instead.
    in div (created by Dropzone)
    in section (created by Dropzone)
    in Dropzone (created by netdava.homebank.app.converter.converter)
    in div (created by netdava.homebank.app.converter.converter)
    in div (created by netdava.homebank.app.converter.converter)
    in netdava.homebank.app.converter.converter
    at invariant (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:1:441>)
    at throwOnInvalidObjectType (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:173:103>)
    at createChild (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:182:360>)
    at reconcileChildrenArray (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:190:1>)
    at eval (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:203:401>)
    at reconcileChildren (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:244:169>)
    at beginWork (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:296:496>)
    at performUnitOfWork (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:434:394>)
    at workLoop (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:436:49>)
    at HTMLUnknownElement.callCallback (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:488:436>)
invariant @ react-dom.development.js:56
throwOnInvalidObjectType @ react-dom.development.js:11834
createChild @ react-dom.development.js:12045
reconcileChildrenArray @ react-dom.development.js:12277
eval @ react-dom.development.js:12600
reconcileChildren @ react-dom.development.js:14403
beginWork @ react-dom.development.js:14864
performUnitOfWork @ react-dom.development.js:19313
workLoop @ react-dom.development.js:19353
callCallback @ react-dom.development.js:150
invokeGuardedCallbackImpl @ react-dom.development.js:200
invokeGuardedCallback @ react-dom.development.js:257
replayUnitOfWork @ react-dom.development.js:18579
renderRoot @ react-dom.development.js:19469
performWorkOnRoot @ react-dom.development.js:20343
performWork @ react-dom.development.js:20255
requestWork @ react-dom.development.js:20229
scheduleWork @ react-dom.development.js:19912
updateContainerAtExpirationTime @ react-dom.development.js:20573
updateContainer @ react-dom.development.js:20658
ReactRoot.render @ react-dom.development.js:20954
eval @ react-dom.development.js:21091
unbatchedUpdates @ react-dom.development.js:20460
legacyRenderSubtreeIntoContainer @ react-dom.development.js:21087
render @ react-dom.development.js:21156
reagent$dom$render_comp @ dom.cljs:17
eval @ dom.cljs:41
eval @ dom.cljs:36
netdava$homebank$app$core$render @ core.cljs:26
netdava$homebank$app$core$main @ core.cljs:31
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:2485
Show 4 more frames
react-dom.development.js:17118 The above error occurred in the &lt;div&gt; component:
    in div (created by Dropzone)
    in section (created by Dropzone)
    in Dropzone (created by netdava.homebank.app.converter.converter)
    in div (created by netdava.homebank.app.converter.converter)
    in div (created by netdava.homebank.app.converter.converter)
    in netdava.homebank.app.converter.converter

Consider adding an error boundary to your tree to customize error handling behavior.
Visit <https://fb.me/react-error-boundaries> to learn more about error boundaries.
logCapturedError @ react-dom.development.js:17118
logError @ react-dom.development.js:17154
expirationTime.callback @ react-dom.development.js:18066
commitUpdateEffects @ react-dom.development.js:16434
commitUpdateQueue @ react-dom.development.js:16464
commitAllLifeCycles @ react-dom.development.js:17384
callCallback @ react-dom.development.js:150
invokeGuardedCallbackImpl @ react-dom.development.js:200
invokeGuardedCallback @ react-dom.development.js:257
commitRoot @ react-dom.development.js:18949
eval @ react-dom.development.js:20419
exports.unstable_runWithPriority @ scheduler.development.js:256
completeRoot @ react-dom.development.js:20418
performWorkOnRoot @ react-dom.development.js:20347
performWork @ react-dom.development.js:20255
requestWork @ react-dom.development.js:20229
scheduleWork @ react-dom.development.js:19912
updateContainerAtExpirationTime @ react-dom.development.js:20573
updateContainer @ react-dom.development.js:20658
ReactRoot.render @ react-dom.development.js:20954
eval @ react-dom.development.js:21091
unbatchedUpdates @ react-dom.development.js:20460
legacyRenderSubtreeIntoContainer @ react-dom.development.js:21087
render @ react-dom.development.js:21156
reagent$dom$render_comp @ dom.cljs:17
eval @ dom.cljs:41
eval @ dom.cljs:36
netdava$homebank$app$core$render @ core.cljs:26
netdava$homebank$app$core$main @ core.cljs:31
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:2485
Show 3 more frames
shadow.module.main.append.js:4 An error occurred when calling (netdava.homebank.app.core/main)
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:2485
main.js:1672 An error occurred when loading shadow.module.main.append.js
env.evalLoad @ main.js:1672
(anonymous) @ main.js:2485
main.js:1673 Invariant Violation: Objects are not valid as a React child (found: object with keys {onKeyDown, onFocus, onBlur, onClick, onDragEnter, onDragOver, onDragLeave, onDrop, ref, tabIndex}). If you meant to render a collection of children, use an array instead.
    in div (created by Dropzone)
    in section (created by Dropzone)
    in Dropzone (created by netdava.homebank.app.converter.converter)
    in div (created by netdava.homebank.app.converter.converter)
    in div (created by netdava.homebank.app.converter.converter)
    in netdava.homebank.app.converter.converter
    at invariant (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:1:441>)
    at throwOnInvalidObjectType (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:173:103>)
    at createChild (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:182:360>)
    at reconcileChildrenArray (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:190:1>)
    at eval (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:203:401>)
    at reconcileChildren (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:244:169>)
    at beginWork (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:296:496>)
    at performUnitOfWork (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:434:394>)
    at workLoop (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:436:49>)
    at renderRoot (<http://localhost:3000/js/cljs-runtime/module$node_modules$react_dom$cjs$react_dom_development.js:439:68>)
env.evalLoad @ main.js:1673
(anonymous) @ main.js:2485

Andrei Stan 2020-11-10T12:43:10.126200Z

thheller 2020-11-10T12:44:39.126400Z

hmm looks like reagent doesn't treat the props as props but as a child

thheller 2020-11-10T12:44:49.126600Z

whats the code you have now?

Andrei Stan 2020-11-10T12:48:10.126800Z

(defn converter [app-state] [:<> [:div.ui.centered.grid.container [:div.column {:style {:max-width 450}} [:h1 "Homebank-OFX"] (js/console.log Dropzone) [:> ui/Form [csv-file-input app-state] [select-iban app-state] [select-currency app-state] [remember-data-checkbox app-state]] [convert-btn app-state] (react/createElement Dropzone nil (fn [^js arg] (r/as-element [:section [:div (.getRootProps arg) [:input (.getInputProps arg)] [:p "drag'n drop"]]]))) ]]])

Andrei Stan 2020-11-10T12:48:45.127Z

i copy-paste the entire wrapper, to see where i create Dropzone

thheller 2020-11-10T12:50:10.127200Z

try [:&gt; "div" (.getRootProps arg) ...] instead of the [:div ...].

thheller 2020-11-10T12:50:40.127400Z

(and again for the [:&gt; "input" ...] in case the error changes)

Andrei Stan 2020-11-10T12:50:54.127600Z

react-dom.development.js:56 Uncaught Invariant Violation: Objects are not valid as a React child (found: object with keys {onKeyDown, onFocus, onBlur, onClick, onDragEnter, onDragOver, onDragLeave, onDrop, ref, tabIndex}). If you meant to render a collection of children, use an array instead.
    in div (created by Dropzone)
    in section (created by Dropzone).....

thheller 2020-11-10T12:51:56.127800Z

yeah that goes beyond my reagent knowledge. I don't know how to make it use the object as props instead of a child. you can always just use react/createElement

thheller 2020-11-10T12:53:05.128Z

(react/createElement Dropzone nil
       (fn [^js arg]
         (react/createElement "section" nil
           (react/createElement "div"
             (.getRootProps arg)
             (react/createElement "input" (.getInputProps arg))
             (react/createElement "p" nil "drag'n drop")))))

thheller 2020-11-10T12:53:29.128200Z

not exactly pretty but should work

Andrei Stan 2020-11-10T12:56:02.128400Z

thank you very much 🙂 for the help and your time

Andrei Stan 2020-11-10T12:56:06.128600Z

it works

Andrei Stan 2020-11-10T12:56:07.128800Z

testing

thheller 2020-11-10T12:56:41.129100Z

I'm sure there is a way to do this via reagent too. might be worth looking into to make it less ugly 🙂

Andrei Stan 2020-11-10T12:57:19.129300Z

i like it as it is now, but i also want to learn reagent too, so i will try to find out what's the problem

👍 1
borkdude 2020-11-10T15:59:49.130300Z

I'm getting a warning for:

(- (ocall js/d3 "bisect" r x) 1)
WARNING: cljs.core/-, all arguments must be numbers, got [#{js/clj-nil clj-nil} number]
Doesn't seem legit to me?

borkdude 2020-11-10T16:00:25.130900Z

unless the CLJS analyzer knows the return type of d3.bisect statically, which would seem advanced to me

borkdude 2020-11-10T16:00:49.131200Z

ocall is from [oops.core :refer [oget ocall]]

borkdude 2020-11-10T16:09:40.131700Z

What are your best tricks to cut out spec from production builds? Right now I'm refactoring all the specs into their own source folder and excluding that in prod

dnolen 2020-11-10T17:08:21.132100Z

managing via the classpath or by separate project seems fine

👍 1
2020-11-10T17:54:09.133100Z

Does anyone have any experience on how to get the doo plugin to work with :target :bundle?

2020-11-10T17:55:35.134400Z

Like, it seems to try to run the output in :output-to, but I'd like to tell it to run the output of the npx webpack command.

2020-11-10T17:56:17.135400Z

(Alternatively, does anyone have any recommendations for running tests defined with deftest?/

2020-11-10T18:04:46.135500Z

I have worked on a library that has both a Clojure/Java and ClojureScript flavor of it, with tests written using deftest forms, and run in an automated fashion from the command line, for both flavors. The library is core.rrb-vector, and has no dependence upon running in a browser, so the automated tests are all run in a browser-less JavaScript runtime. Is that of interest to you?

2020-11-10T18:06:10.135900Z

Yes it is.

2020-11-10T18:06:30.136100Z

This is the library? https://github.com/clojure/core.rrb-vector

2020-11-10T18:07:54.136400Z

It is

2020-11-10T18:09:08.136600Z

If you clone it on a Linux or Mac, change to its root directory, and run ./script/sdo test, it should run a short version of the ClojureScript test suite.

2020-11-10T18:09:41.136800Z

Okay cool, thanks.

2020-11-10T18:10:52.137Z

It requires Node.js to be installed for the JavaScript runtime (not sure whether I have hooks in there to pick a different one or not).

2020-11-10T18:15:37.137200Z

It is I think the only Clojure project I have worked on that has a ClojureScript part to it, so I make no claims that it is a clean/beautiful/recommended/etc. way to execute such tests.

borkdude 2020-11-10T18:24:16.137400Z

@leif I also have a couple of projects using the cljs-test-runner for deps.edn which uses doo under the hood

2020-11-10T18:24:41.137600Z

OH, I'd also be interested in looking at that.

borkdude 2020-11-10T18:25:27.137800Z

@leif for example: https://github.com/borkdude/sci/blob/master/script/test/node

2020-11-10T18:27:35.138200Z

Thanks

2020-11-10T18:28:06.138400Z

And it looks like cljs-opts.edn is where you're using doo?

borkdude 2020-11-10T18:28:33.138700Z

I'm using this tool: https://github.com/Olical/cljs-test-runner which uses doo

2020-11-10T18:29:32.139100Z

Ah, okay, I get it now.

2020-11-10T18:29:33.139300Z

Thanks

p-himik 2020-11-10T23:15:25.139900Z

If you need to pass some Hiccup to a React component, wrap in in reagent.core/as-element.

p-himik 2020-11-10T23:15:48.140100Z

Reagent documentation has a lot of React docs and examples.