Fork me on GitHub
#reagent
<
2017-02-17
>
iku00088805:02:32

Has anyone ever seen on-click events not firing on mobile safari with reagent?

iku00088805:02:09

I am thinking this is a related issue, but things are hard to track down... https://github.com/facebook/react/issues/1169

piotr-yuxuan09:02:45

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?

pesterhazy11:02:52

@piotr2b, do you have some code for context?

piotr-yuxuan12:02:32

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.

tomaas18:02:00

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.

tomaas18:02:27

what does the last part mean component state

tomaas18:02:29

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

juhoteperi18:02:41

It is rarely used with Reagent as using closure & local atom is easier

tomaas18:02:17

thanks, nice

pesterhazy18:02:25

@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

pesterhazy18:02:02

you'll just need to look up how to do it using javascript, then translate to cljs

pesterhazy18:02:27

in your component you can use a callback ref to get a reference to the dom node, if that's what you're asking

pesterhazy18:02:54

@juhoteperi actually I think reagent's api doesn't expose the component state

pesterhazy18:02:21

the functions you linked to access a state atom

pesterhazy18:02:48

which as you mention is kind of pointless as it's easy to build that yourself using a closure

pesterhazy18:02:03

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)

piotr-yuxuan22:02:54

@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.

souenzzo23:02:21

(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)

pesterhazy23:02:22

you need a form-2 component