Fork me on GitHub

Hello, I have never used Reagent and am trying to find out whether it is easy enough to build a basic web app which would have a few buttons, and little state. Specifically, I want to know whether it is easy to write repeatable data: the data items would be shown in html tables; and also, draw onto canvases and interact with graphic libs such as d3.js…Would I need to also learn Re-Frame to do the above? thanks for any comment!


@kingcode you can do all of those things with reagent. keep in mind reagent adds a layer of abstraction on top of react in addition to its state management techniques. re-frame adds considerably more structure to reagent’s built-in state management. so, yes you can do what you are asking. no you don’t need re-frame


@lee.justin.m Thank you..yes indeed I am aware of React, and have figwheel installed and running with Cider. I am trying to decide which will be faster - om or reagent/re-frame.


I meant faster to learn..


Reagent (biased opinion)


if you are already familiar with react, reagent is probably the least amount of stuff you need to learn

kingcode02:10:18 familiar with React principles 🙂 but hopefully that should be enough.


I did play with Reagent in the past…briefly though


well that’ll help. just run through the docs directory on github and you should be up and running pretty quickly


I remember I had a question with regards to the need to use the exact same variable names within component declarations in Reagent when returning a function


@kingcode if you're familiar with just the concept of react lifecycle (will mount, render did mount) should be good to go for quite a while. Not much else from react is needed for 95 percent of stuff


I will check it out and come back with my question later - thank you @gadfly361 as well


Yeah, those lifecycle methods are in both reagent and om..


Will go with reagent for now - thanks!


@kingcode if you are interested in d3, I'd recommend this library I made:

👍 4

@gadfly361 Thanks, will check it out….I need to build bar charts and plot point graphs - will that be possible?




Stay tuned, and talk to you later (via more questions hehe)

👍 4

I’ve had good times making simple declarative charts with

(defn my-bar-chart []
  (let [data [{:a "cats" :b 200} {:a "dogs" :b 300}]]
    [:> rc/ResponsiveContainer {:width "100%" :height 300}
     [:> rc/BarChart {:data data}
      [:> rc/CartesianGrid]
      [:> rc/Legend]
      [:> rc/Tooltip]
      [:> rc/YAxis]
      [:> rc/XAxis {:dataKey :a}]
      [:> rc/Bar {:dataKey :b :label false :fill "#ffd400"}]]]))
Available in cljsjs [cljsjs/recharts "1.1.0-3"]


form-2 is not rendering. I made a simple test button, then changed it over to form-2 and nothing happens. I checked the code and found mount-components does call reagent/render.


I just tried an example from the purelyfunctional page and displays.


(defn counting-button [txt]
  (let [state (r/atom 0)] ;; state is accessible in the render function
    (fn [txt]
       {:on-click #(swap! state inc)}
       (str txt " " @state)])))


I have plenty of test components displaying but none in form-2.


That should work, the error must be elsewhere in the code @llsouder


something is wrong. I just commented out almost everything and I still see println I commented out in my figwheel repl. Other things are changing but I don't see my new println.


maybe cljs didn't build? the function looks fine


Try Shift-Reload, restarting the dev env, and cleaning build artifacts (roughly in that order)


I deleted target/cljs, (clean-builds) in fig, and shift-reload And finally got rid of yesterday's debug prints


but still no form-2 components. I put a println of the txt in the counting-button, before the let and now I see that print but no counting button


There's no println in the snippet you posted. How do you expect us to be able to guess what problem you're talking about? It helps if you boil it down to a minimum and post the full namespace e.g. as a gist.


I think I got it... testing...


I was calling my components in a list not a vector so () evaluated my function and [] does not. [] appears to work. still... waiting for run/fig to come up...


Confirmed! It make sense. noob mistake!


There is still some weird dev crap happening as far as clean builds, figwheel and my environment but at least the world is somewhat sane again.