Fork me on GitHub
#beginners
<
2023-08-02
>
Nim Sadeh02:08:04

I have run into the following error after starting a Krell project from the repo:

Could not locate reagent/react_native__init.class, reagent/react_native.clj or reagent/react_native.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
I am unable to resolve this error and have spent a lot of time trying to. I am getting quite frustrated with the dev experience of setting up Clojure projects 😞

👍 2
Aziz Aldawood02:08:00

can you list screenshot of your file structure? on a side note: setting up projects in any new language is always a pain (for me at least). I view as a challenge because it forces to understand how different pieces in the project work together

Nim Sadeh02:08:10

Clojure appears difficult on another level in this category - there are so many files (why do I have Ruby files???). Elm is where I came from and it was extremely simple. Here is the screenshot

Aziz Aldawood02:08:28

can I see inside src and folders below src

Aziz Aldawood03:08:46

I was hoping you missed a dash in a file name 😬 we need to dig deeper. my next step would to look at deps.edn and the command you ran. Also, not sure if this would be relevant but what os are you using?

Nim Sadeh03:08:28

mac OS, Ventura 13.4

Nim Sadeh03:08:45

{:main thirdplace_krell.core
 :output-to "target/main.js"
 :output-dir "target"
 :language-out :es5}

Nim Sadeh03:08:06

this was generated automatically by krell except the language out command

Nim Sadeh03:08:24

clj -M -m krell.main -co build.edn -c -r

Nim Sadeh03:08:31

appreciate the help! I took a bet on Cljs over straight up RN as I was hoping it would make me more productive and I would enjoy developing more, but now weeks later after learning cljs and days of trying to bootstrap a project I am wondering if it was a waste and I should just do a standard TS/RN repo

Aziz Aldawood03:08:23

are you sure that was your deps.edn file?

Nim Sadeh03:08:09

sorry, I gave you my build.edn. Here's the deps.edn

{:deps {io.vouch/krell {:git/url ""
                        :sha "08f2bfea96aa48feb8511851e37f5948453986e5"}
        io.vouch/reagent-react-native {:git/url ""
                                       :sha "0fe1c600c9b81180f76b94ef6004c2f85e7d4aa0"}
        reagent/reagent {:mvn/version "0.10.0"
                         :exclusions [cljsjs/react cljsjs/react-dom]}}}

Nim Sadeh03:08:26

I did not touch it, it came with the project

Aziz Aldawood03:08:17

i am looking at this https://github.com/vouch-opensource/krell/wiki/Reagent-Tutorial Have you tried removing language-out key in your build file?

Nim Sadeh03:08:50

Trying now - fyi without it, Krell can't work with the Hermes engine

Nim Sadeh03:08:53

ended up deleting the target folder and re-compiling the project and it worked, but still working on getting JS files to import. If I can't get it done within the next 20 minutes I'll probably just use RN vanilla, this isn't worth it for me anymore

Nim Sadeh03:08:01

I haven't actually coded anything in days

Nim Sadeh03:08:43

I keep getting ; TypeError: Cannot read property 'pprint' of undefined after jacking-in my editor (VSCode) and importing a JavaScript file using js/require in a Krell setup. This applies to all forms and cannot be removed unless I redo the jack-in process

Nim Sadeh03:08:44

To replicate: (comment (js/require "../js/test.js"))

Nim Sadeh03:08:05

This will completely destroy the current repl session and requires that it be restarted

Nim Sadeh03:08:17

Which isn't fun since it takes a while

Nim Sadeh03:08:53

Current error message:

ERROR  Could not evaluate form: try{var sb__2458__auto___7133 = (new goog.string.StringBuffer());
var sbw__2459__auto___7134 = (new cljs.core.StringBufferWriter(sb__2458__auto___7133));
var form__2460__auto___7135 = (function (){var ret__2462__auto__ = require("../src/js/SlidingPanel.js");
(cljs.core._STAR_3 = cljs.core._STAR_2);

(cljs.core._STAR_2 = cljs.core._STAR_1);

(cljs.core._STAR_1 = ret__2462__auto__);

return ret__2462__auto__;
})();
cljs.pprint.pprint.call(null,form__2460__auto___7135,sbw__2459__auto___7134);

cljs.core.str.cljs$core$IFn$_invoke$arity$1(sb__2458__auto___7133);
}catch (e7132){var e__2463__auto___7136 = e7132;
(cljs.core._STAR_e = e__2463__auto___7136);

throw e__2463__auto___7136;
} [TypeError: Cannot read property 'pprint' of undefined]

pez09:08:06

Is it any JS file, or could it be something particular with that one?

Nim Sadeh11:08:38

It’s any JS file. I tried creating a basic one with a function that returns 42.

adham12:08:42

Hey all, I have a question about web development. I have learned to create a front-end with ClojureScript and Tailwindcss, I learned to make a backend with Clojure and connect it to a database, also learned how to make a jetty server and have it receive requests with ring. Now my question is how do I link those in the following fashion, the front-end makes a request to the back-end and receives a response that it can consume as Clojure(Script) data. For example my back-end function returns the following

[1 2 3]
and the following for my router
(def app
  (ring/ring-handler
   (ring/router
    ["/"
     [":symbol/" get-data]])))
This is my handler
(defn get-data [req]
  (let [symbol-name (get-in req [:path-params :symbol])]
    (r/response (db/back-end-func symbol-name)))))
The response returns 123 and not the vector. What am I missing? What do I need to learn? From my search I found the following: • https://www.reddit.com/r/Clojure/comments/y4op7q/how_do_i_send_data_between_front_end_and_back_end/ which leads to http-kit which seems popular according to https://www.reddit.com/r/Clojure/comments/x38puy/which_library_you_are_using_for_web_server_why/

oly12:08:17

just a few things, when you say response is returning 123 I am guessing this is client side as (r/response (db/back-end-func symbol-name)) should be returning a map with a :body key, if its client side I would look at the headers and hazard at a guess you need to parse your vector to a json string or edn string to send it to the client where you can read it in your client side application.

adham13:08:04

When I evaluate (r/response (db/back-end-func symbol-name)) I get {:status 200, :headers {}, :body (1 2 3)} I was wrong about the return being a vector, it looks like it's a lazy sequence, does that affect it? I tried wrapping my return with a (vec) now my map is {:status 200, :headers {}, :body [1 2 3]} and when I check the response in a browser I see no value. When you say parse it as a edn or json string is it something similar to (str (to-json my-vector)) ?

oly13:08:25

yeah basically you can't send raw data structures over the wire so usually you translate to json or edn

adham13:08:27

Understood, I did manage to get a response that is a string, now time to request it inside my cljs frontend. Any direction before I go search?

oly13:08:12

is it a json string though ?

adham13:08:39

No, just [1 2 3]

adham13:08:02

I assume I should make it edn or json first, correct?

oly13:08:52

yes correct

oly13:08:06

you can use something like this https://github.com/JulianBirch/cljs-ajax on the client side

oly13:08:20

you can also look into ring middleware to do the conversions, I use ring reitit swagger I think the conversion is done by the coersion middleware if i remember

oly13:08:13

actually this is the middleware I am using for json muuntaja/format-response-middleware

oly13:08:44

that's comming from reitit so not much use if you are not using reitit for routing

oly13:08:00

but google json ring middleware and I am sure you will find something

oly13:08:21

or convert it yourself befor sending it into the response function

adham13:08:41

Thank you, this gives me some direction to look, I am using reitit.ring here so I can look into those. For now I'll try the simple approach of converting before I send then dive deeper into it, thanks again!

oly13:08:17

if your using reitit then you can import this [reitit.ring.middleware.muuntaja :as muuntaja]

oly13:08:57

yeah simple version will give you a good understanding 🙂

adham13:08:39

Yep I'm new to web development in addition to being new to CLJS, there's a lot to learn but that's where the fun is

adham17:08:29

I reached something... I was able to get the back-end to send a JSON and I was able to check that in the browser. Now to use that in the front-end I have the following

(fn []
                  (p/let [response (js/fetch "")
                          value (.json response)
                          data (js->clj value :keywordize-keys true)]
                    (swap! stock-data (fn [] data))))
Where data is the data in ClojureScript form, I'm running (swap!) that affects a global (r/atom) .

oly07:08:24

okay great glad you made progress 🙂