This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-11
Channels
- # admin-announcements (9)
- # arachne (1)
- # boot (125)
- # cider (5)
- # clara (34)
- # cljs-dev (11)
- # cljsjs (19)
- # clojure (164)
- # clojure-greece (7)
- # clojure-nl (2)
- # clojure-russia (5)
- # clojure-spec (3)
- # clojurescript (28)
- # clojurex (4)
- # core-async (3)
- # cursive (2)
- # datomic (3)
- # hoplon (268)
- # jobs (4)
- # keechma (2)
- # lambdaisland (1)
- # lein-figwheel (5)
- # leiningen (5)
- # off-topic (3)
- # om (3)
- # onyx (16)
- # re-frame (5)
- # reagent (31)
- # robots (1)
- # spacemacs (3)
- # specter (89)
- # untangled (1)
- # yada (26)
You should generally ignore :render
. It corresponds to the raw React render function which only gets this
as a parameter. Instead, you should use :reagent-render
which will be given props as parameters.
Actually, this is probably what you are after: https://www.martinklepsch.org/posts/props-children-and-component-lifecycle-in-reagent.html
I'll spend some more time reading the source, so I'll get there eventually, but if anyone has written things that would help me when trying to understand the code... that would be helpful 🙂
Hi all, I'm working on my first cljs project, and I'm using reagent. I used the lein reagent template and have three src subdirectories: cljs, clj, and cljc. In cljs I have projname/core.cljs, and charts/charts.cljs, where I use highcharts. The charts are working great, but now it's time for me to actually pull the data from the db to give to the charts. Where should this code go? I'd like to put it in a "db" folder but not sure whether this should be clj, or cljc ... and how to then :require it from my charts.cljs file (just a regular :require [db.db :as db] ....?) Please forgive my ignorance on this; it's a bit different from a regular clojure project and I'm still figuring things out.
@joshjones: I'll assume you have some database on the server side, you will need to implement an API endpoint so your Reagent app can request that data from the server
@plexus - thanks for your reply! I have a local mysql database. I have clojure code already written that performs the queries, etc. I just need a way to reference the clojure functions.
the thing is, you can't just "reference" those functions from ClojureScript, they live in separate worlds
your reagent app is compiled to JavaScript and runs in the browser, your database runs on the server
I would look into - Compojure https://github.com/weavejester/compojure - ring-middleware-format https://github.com/ngrunwald/ring-middleware-format - cljs-http https://github.com/r0man/cljs-http
ok ... I will do some research, and I appreciate you pointing me in the right direction. I'm sure after my research I will have some more questions. Thanks for your patience with a cljs newbie
ring-middleware-format and cljs-http won't be there yet, you'll have to add them to project.clj
actually I would use this one instead of cljs-http https://github.com/JulianBirch/cljs-ajax
it's a thin wrapper around XhrIO which is all you really need, cljs-http is built on core.async which will makes things more complex than necessary
@joshjones: here's an example app that calls a JSON API endpoint over AJAX https://github.com/plexus/reagent-ajax-json-example/commit/2a39b6c97bfaf46866e9a11f095b7275fa677d0c
I started from lein new reagent reagentnew
, then applied these changes. That's all you need
thanks @plexus -- I think a separate sample project like this is a great idea, and then I can integrate it into my existing project
yeah exactly, I know how tricky it can be to get all the moving pieces in the right place the first time
now that I think about it, I used lein new figwheel proj
so that I could use figwheel to automatically update upon saving, so that may have muddied my mental waters a bit