This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-17
Channels
- # beginners (52)
- # boot (116)
- # cider (21)
- # cljs-dev (44)
- # clojure (104)
- # clojure-dev (82)
- # clojure-greece (5)
- # clojure-japan (4)
- # clojure-nl (14)
- # clojure-russia (65)
- # clojure-serbia (3)
- # clojure-spec (38)
- # clojure-uk (9)
- # clojure-ukraine (1)
- # clojurescript (65)
- # clojurewest (1)
- # community-development (1)
- # core-logic (3)
- # cursive (5)
- # data-science (9)
- # datomic (13)
- # emacs (45)
- # euroclojure (1)
- # hoplon (2)
- # instaparse (23)
- # javascript (1)
- # jobs (2)
- # klipse (43)
- # leiningen (8)
- # lumo (25)
- # off-topic (7)
- # om (13)
- # om-next (3)
- # onyx (11)
- # pedestal (12)
- # planck (19)
- # proton (1)
- # re-frame (26)
- # reagent (26)
- # remote-jobs (13)
- # ring-swagger (23)
- # spacemacs (1)
- # untangled (3)
I am thinking this is a related issue, but things are hard to track down... https://github.com/facebook/react/issues/1169
Hello here 🙂 I’ve got a hiccup form which is rendered as rich text. This text is meant to be selected. Is it possible to use Reagent to get the string which can be selected from this hiccup form?
@piotr2b, do you have some code for context?
It’s not a big deal, just a fun little riddle I stumbled upon. At first I thought it would be easy but I looked to reagent API but actually I found nothing obvious.
Mounted components are only re-rendered when their parameters have changed. The change could come from a deref’ed atom, the arguments passed to the component or component state.
looking at this example, seconds-elapsed
is a closed variable over render function, which is considered local state of component, right? However, seconds-elapsed
is deref’ed atom also
Component state is the React component state: https://github.com/reagent-project/reagent/blob/master/src/reagent/core.cljs#L119-L152
It is rarely used with Reagent as using closure & local atom is easier
@piotr2b, it used to be that programmatic copy 'n paste was possible only through flash, but I suspect that modern browsers support it through some sort of API
you'll just need to look up how to do it using javascript, then translate to cljs
in your component you can use a callback ref to get a reference to the dom node, if that's what you're asking
it's explained here: https://presumably.de/reagent-mysteries-part-3-manipulating-the-dom.html
@juhoteperi actually I think reagent's api doesn't expose the component state
the functions you linked to access a state atom
which as you mention is kind of pointless as it's easy to build that yourself using a closure
you can implement the get-initial-state
lifecycle method and access (.-state this)
in a component (though I'm not sure why you would do that, given reagent's state management)
@pesterhazy actually, thanks for your answer 🙂 The part you talk about “clipboard manipulation in JS” has been solved in cljs, it’s no longer a problem for me 😉 the only remaining pain point is how to retrieve “string-to-be-selected” from a component.
@pesterhazy you can easily use this: https://github.com/cljsjs/packages/tree/master/clipboard
(defn fetchUrl
[url state]
(xhr/request :url url
:success (fn [io]
(let [response (.getResponseJson io)]
(println response) ;; ok!
(reset! state response)))))
(defn home-page []
(let [state (reagent/atom "abc")]
[:div
[:button {:on-click #(fetchUrl "" state)} "Here"]
[:br]
[:p (str @state)]]))
Why does this doesnt work?
(print my json but not update my :p
)you need a form-2 component