Questions tagged [reagent]

Reagent provides a minimalistic interface between ClojureScript and React.

It allows you to define efficient React components using nothing but plain ClojureScript functions and data, that describe your UI using a Hiccup-like syntax.

342 questions
20
votes
4 answers

Why are multi-methods not working as functions for Reagent/Re-frame?

In a small app I'm building that uses Reagent and Re-frame I'm using multi-methods to dispatch which page should be shown based on a value in the app state: (defmulti pages :name) (defn main-panel [] (let [current-route (re-frame/subscribe…
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
18
votes
3 answers

Reagent :component-did-mount

I'm trying to set the initial focus on an input element (defn initial-focus-wrapper [element] (with-meta element {:component-did-mount #(.focus (reagent/dom-node %))})) (defn chat-input [] (fn [] [initial-focus-wrapper [:input…
Brendanator
  • 833
  • 1
  • 8
  • 15
16
votes
2 answers

Reagent React Clojurescript Warning: Every element in a seq should have a unique :key

I have copied a two year old gist from here. It is now working with Figwheel and uses a more recent version of Reagent/React. I am looking for a generic way of isolating this warning message that comes to the Javascript console: Warning: Every…
Chris Murphy
  • 6,411
  • 1
  • 24
  • 42
15
votes
2 answers

How To Detect "Enter" Keypress in Reagent?

Given the following code: [:input {:type "text" :value (:text @app-state) :on-change (fn [e] (if (= 31 (.-keyCode e)) (println "ENTER") (println "NOT…
Michiel de Mare
  • 41,982
  • 29
  • 103
  • 134
13
votes
3 answers

How do I loop through a subscribed collection in re-frame and display the data as a list-item?

Consider the following clojurescript code where the specter, reagent and re-frame frameworks are used, an external React.js grid component is used as a view component. In db.cls : (def default-db {:cats [{:id 0 :data {:text "ROOT" :test 17} :prev…
nilo de roock
  • 4,077
  • 4
  • 34
  • 62
12
votes
1 answer

What is the difference between reg-event-db, reg-event-fx and reg-event-ctx in Re-frame?

There are 3 event fns in Re-frame, I can do the same thing with both reg-event-db and reg-event-fx. What is the main difference between reg-event-db, reg-event-fx and reg-event-ctx? When should I use reg-event-fx over reg-event-db or vice versa.
Ertuğrul Çetin
  • 5,131
  • 5
  • 37
  • 76
12
votes
1 answer

how to do ajax request in clojurescript with reagent?

Say I have a component which needs to request some data from server before rendering. What I have now is something like with cljs-ajax library: (def data (r/atom nil)) (defn component [id] (r/create-class {:reagent-render simple-div …
LoveProgramming
  • 2,121
  • 3
  • 18
  • 25
11
votes
2 answers

Clojurescript, Reagent: pass atoms down as inputs, or use as global variables?

I'm writing a Clojurescript app, using Reagent to make my components reactive. I have a simple question. Should I Pass my atoms as inputs through my components, or Use the atoms as global variables and let them 'side-affect' my components? In the…
Boyentenbi
  • 417
  • 4
  • 14
11
votes
1 answer

use predefine react component from reagent?

I have some external UI with abstraction of react components and I want to reuse them from reagent, is there any way to directly render predefined react component just by passing data from clojurescript. I am a clojurescript beginner.
piyushmandovra
  • 4,219
  • 3
  • 19
  • 30
10
votes
2 answers

Are reagent-forms meant to be using with re-frame?

I'm building an application with re-frame and I'm wondering if reagent-form are meant to be used with re-frame or not, as reagent-form brings in its own way of handling state which is different than re-frame.
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
10
votes
2 answers

How to get query parameters in clojurescript?

I'm using secretary and reagent. This is my code : (def view (atom nil)) (defn layout [view] [:div @view]) (reagent/render-component [layout view] (.getElementById js/document "message")) (secretary/set-config! :prefix "") (secretary/defroute…
Viktor K.
  • 2,670
  • 2
  • 19
  • 30
10
votes
1 answer

Ajax GET with Reagent

I am doing an Ajax GET from my Reagent application, to load some stuff from the database. I am not entirely sure what is the best way of getting the result of such ajax call to my page, considering that if I put it in an atom, then Reagent…
Helios
  • 457
  • 6
  • 17
10
votes
1 answer

Reagent input not updating

I'm trying to build a Hello World app with Reagent/React. I tie an input with an atom using :value/:on-change combo. However, when I type, the input remains empty: (defn new-user [] ; Atom declared in an inner `let`. (let [v (atom "")] …
kamituel
  • 34,606
  • 6
  • 81
  • 98
9
votes
1 answer

Tracking mouse in clojurescript / reagent / reagi?

I'm trying to get to grips with reagent in clojurescript with a simple drawing program. I'm looking for an example of how to access the mouse position in a principled "FRP" inspired style with Reagi. In various reagent examples I can see things that…
interstar
  • 26,048
  • 36
  • 112
  • 180
9
votes
3 answers

Keeping Client State Up-To-Date In Reagent / Clojurescript

I am not sure on the best way to go about this: I have a web application I am writing which implements basic CRUD functionality for a number of "Project" objects. So, a user can create his/her own set of Projects. I have written a REST API for…
Rob Moffat
  • 465
  • 5
  • 11
1
2 3
22 23