reagent

A minimalistic ClojureScript interface to React.js http://reagent-project.github.io/
p-himik 2020-06-12T04:09:27.117400Z

I really doubt that. Try to find the root cause of the issue. utils.date is not a function really sounds like a usage error.

valtteri 2020-06-12T04:40:22.117700Z

Fair. ๐Ÿ™‚ I edited my statement โ€œbestโ€ => โ€œeasyโ€.

1๐Ÿ‘
EmmanuelOga 2020-06-12T09:13:38.121800Z

Sup! I want to just render two spans inside some container: (rdom/render [:div.wrapper [:span "Hello"] [:span "world"]] some-dom-elem). This works allright, but what if I want to remove the :div.wrapper? Can't seem to find a way to render a list of elems without a root element. This is annoying because my html ends up using an unneeded wrapper: <div id="wrapper"><div class="wrapper"><span... etc

EmmanuelOga 2020-06-12T09:19:17.122500Z

Oh, that was easy, I just replace :div with :<> . Perfect, thx!

Daniel Hutzley 2020-06-12T22:09:31.124800Z

Hey, I am having some trouble building a release binary. From a fresh install of the template, how would I build a html webpage that I can move onto a server and use?

2020-06-12T22:14:01.126100Z

@endergeryt if it's a lein template, use lein uberjar to create a fat jar, the resulting jar (there's two, you want the one with "standalone" in the name) can be run via java -jar ...

Daniel Hutzley 2020-06-12T22:14:24.126900Z

When I run the uberjar, it drops me into a clojure REPL

2020-06-12T22:15:05.127300Z

oh - it must be avoiding aot

Daniel Hutzley 2020-06-12T22:15:31.128Z

How would I prevent that?

2020-06-12T22:15:41.128200Z

try java -jar my-standalone.jar -m my.ns

2020-06-12T22:16:24.129Z

you don't need aot, it just means your startup is slightly more verbose a command line

Daniel Hutzley 2020-06-12T22:18:04.129800Z

whenever I do that, it appears to only be looking for clojure and cljc files, but not cljs files

Daniel Hutzley 2020-06-12T22:18:24.130100Z

I should note that I'm using the frontend template

2020-06-12T22:18:41.130500Z

to run cljs files, you need to connect to the clj server

2020-06-12T22:18:59.131100Z

perhaps you want electron rather than reagent if what you want is an app?

2020-06-12T22:19:43.132300Z

https://github.com/Gonzih/cljs-electron

Daniel Hutzley 2020-06-12T22:19:49.132600Z

It's a website, I just used the frontend template. How would I get the clj server running? It works with figwheel

2020-06-12T22:20:49.133600Z

running the main ns created by the template (named based on your creation args) will by default start a web server that serves html providing your reagent cljs app

2020-06-12T22:21:06.133900Z

figwheel is a dev only tool and shouldn't be used in production

Daniel Hutzley 2020-06-12T22:22:00.134400Z

ok, where would the main namespace be located in my sources?

2020-06-12T22:24:50.135300Z

if you created it via lein new reagent foo it would be in src/foo/core.clj if you used lein new reagent org.foo/bar it would be in src/org/foo/bar.clj

Daniel Hutzley 2020-06-12T22:25:41.136300Z

Hm, is there a way to move from the reagent-frontend template to the plain reagent template easily?

2020-06-12T22:27:28.136700Z

oh! I missed that you were using the separate reagent-frontend package, sorry

2020-06-12T22:27:53.137500Z

if you use lein new, there should be very few files to copy over from the other project, that's likely the easiest thing

Daniel Hutzley 2020-06-12T22:28:16.138200Z

Ok, I'll try to create a reagent standard template and transplant the files

2020-06-12T22:29:04.138800Z

I think the main thing is that src/foo.cljs in reagent-frontend becomes src/cljs/foo.cljs in reagent

Daniel Hutzley 2020-06-12T22:33:47.139200Z

How would I get it to not use the router

2020-06-12T22:34:15.139800Z

why would you need it to do that?

Daniel Hutzley 2020-06-12T22:34:45.140500Z

The way the site is constructed is that it uses an atom to control where it is on the site

Daniel Hutzley 2020-06-12T22:34:59.140800Z

Unless the router can modify the atom

2020-06-12T22:35:10.141Z

sounds like you just want a single page

Daniel Hutzley 2020-06-12T22:35:22.141200Z

yeah, that's how I set it up

2020-06-12T22:35:52.141900Z

easiest thing is to use only one route in the router

2020-06-12T22:36:18.142300Z

you can run without a router, but that's definitely not the easy thing to do

2020-06-12T22:37:15.142700Z

even with a SPA you usually end up with routes for serving data queries

2020-06-12T22:40:21.144200Z

anyway, now that I think for a moment longer, the router implements a function, you can just replace it with any other function from request -> response (eg. your page handler), or just have no routes defined and serve everything via static resources (but at that point why even use clojure on the back end, maybe you'd want nginx instead...)

Daniel Hutzley 2020-06-12T22:43:04.144900Z

how do I get it to serve cljs instead of the hiccup?

2020-06-12T22:44:09.145400Z

the original project should have had an http template that pulled in the js from your cljs, and rendered the hiccup

Daniel Hutzley 2020-06-12T22:44:25.145800Z

mount-target?

2020-06-12T22:47:25.147Z

this is the file in reagent-frontend-template: https://github.com/reagent-project/reagent-frontend-template/blob/master/resources/leiningen/new/reagent_frontend/public/index.html I guess the version in reagent compiles from hiccup in the handler ns - but no hiccup should reach the browser https://github.com/reagent-project/reagent-template/blob/master/resources/leiningen/new/reagent/src/clj/reagent/handler.clj

Daniel Hutzley 2020-06-12T23:00:56.148700Z

how would I configure somethiing to just serve it, since I just need it set up as a single page webapp. I just cannot figure out how to compile the frontend into something I can render

lilactown 2020-06-12T23:08:39.149400Z

@endergeryt it looks like the reagent-frontend project has a command to bundle up all of your JS

Daniel Hutzley 2020-06-12T23:08:49.150Z

Ok, what would that be?

lilactown 2020-06-12T23:08:54.150200Z

in the README

lilactown 2020-06-12T23:09:18.150700Z

> Building for production

lein clean
 lein package

lilactown 2020-06-12T23:09:38.151200Z

that will build a production JS bundle, which you can then upload to a file hosting service

Daniel Hutzley 2020-06-12T23:09:49.151400Z

ok, thanks!

2020-06-12T23:10:11.151800Z

oh wow, I really was sending this on a wild goose chase, sorry

Daniel Hutzley 2020-06-12T23:11:28.153100Z

It's fine, honestly I probably wasn't helping the situation much. Thanks for the help!

Daniel Hutzley 2020-06-12T23:14:48.153700Z

What do I do about the stuff in the index.html file? Do I include that too?

lilactown 2020-06-12T23:32:31.154Z

yeah, you can upload that as well if it matches what you want in production

Daniel Hutzley 2020-06-12T23:40:43.154800Z

Um, slight problem. Whenever I try and run the index.html file in the browser, I get the ClojureScript has not been compiled div instead of the real app

lilactown 2020-06-12T23:45:09.155100Z

could be a number of issues. is your JS bundle being loaded?

Daniel Hutzley 2020-06-12T23:45:54.155500Z

how can I check if that is the case? The script tag is there

Daniel Hutzley 2020-06-12T23:48:53.156100Z

I think it's a problem of it trying to run from the root of my filesystem, how do I avoid that

Daniel Hutzley 2020-06-12T23:51:40.156800Z

Yeah, it's just my links trying to go from the root of my filesystem

lilactown 2020-06-12T23:54:08.157100Z

it would say in the console or network tab if the script failed to load

Daniel Hutzley 2020-06-12T23:56:01.157500Z

Yeah, I've figured out the issue. I got it working. Thanks though!