Clojurians
#reagent
<
2016-01-11
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

dvcrn06:01:27

hey reagent guys! I am currently testing out reagent for a react native process but run into some problems...

dvcrn06:01:50

For one particular case I need to pass a rendered component as a property to another component

dvcrn06:01:31

I tried something like this:

(set! js/React (js/require "react-native/Libraries/react-native/react-native.js"))
(def view (r/adapt-react-class (.-View js/React)))

(…)

(assoc :rightCalloutView [view {:flex 1} [text {} "Hi"]])
but that is not rendered

dvcrn06:01:04

plus it is not getting rendered by reagent/render because it is not part of the normal component tree

jaen16:01:05

So I'm trying to use semantic-ui components with reagent and documentation says I should do something like this - http://semantic-ui.com/introduction/integrations.html I thought componentDidUpdate would be called when reagent re-renders the component on some reactive change.

jaen16:01:33

But it doesn't seem to be caleld for me when I use... oh right '

jaen16:01:56

Or no, I thought I wasn't derefing the atom I wanted to be reactive on in render, but I do.

jaen16:01:39

Ah, I see. I keep forgetting that wraps are not really reactive.

jaen16:01:02

Is there anything similar to wrap I could use in form-2? Like so:

(defn component [...]
  (let [reactive (wrap-alternative #(on read) #(on reset))]
    (fn []
        ...)))
and expect it to work similarly to ratom?

gerred19:01:49

is there a Redux-equivalent that works well with Reagent?

jaen19:01:07

You could take a look at re-frame; it's not exactly redux, but inspired by it. (EDIT: turns out I've mixed up flux with redux, my bad)

gerred19:01:50

awesome. I'm trying to move over just because the full React ecosystem has become insane with what you need to bootstrap a project. Reagent (and Elm) both are super nice versus having to start layering Babel, Webpack, Browserify, etc. etc. etc. good luck, have fun.

gerred19:01:36

I miss the days of just using Gulp :disappointed:

jaen19:01:39

Well, you can't run from some of those here either - if you need a JS library that has modules you have to compile them out with webpack or browserify though.

gerred19:01:05

fair enough.

jaen19:01:06

But most of the time yeah, setting up a project with boot is pretty straightforward.

gerred19:01:59

ooh, that's perfect.

gerred19:01:30

yeah. I've been getting hung up on Clojure itself on the JVM, but ClojureScript is really nice and PureScript just isn't doing it for me.

jaen19:01:44

The parts are a bit outdated (it uses jQuery-like domina for example) but the general principle is the same.

jaen19:01:46

Well, if you came here before boot it would probably not be as nice to do Clojurescript; lein cljsbuild setups tended to be fiddly.

jaen19:01:53

Boot is a breeze though.

jaen19:01:18

Also, out of curiosity - what you don't like about pursecript?

gerred19:01:31

I think it's mostly my lack of understanding about PureScript itself. I also just think front end packaging is in a dismal state, and everything's careening toward webpack, and I think PureScript is very webpack focused.

gerred19:01:02

at least the book is with their purs-loader.

gerred19:01:17

maybe I need to spend time with WebPack, but holy crap, you take a break for 8 months and it's all different.

jaen19:01:43

Well yeah, that's webdevelopment for you. I have a feeling the most of web ecosystem likes to hipster it up quite a lot.

jaen19:01:53

If it's older than a couple months it's not cool anymore.

jaen19:01:20

Clojure/Clojurescript are somewhat tempered by theri Java heritage, I suppose.

jaen19:01:25

RE: my issue earlier I've created a reactive value with callbacks both for getting and setting the value - https://gist.github.com/jaen/c59a3e0abcf0c6f6ade2 - it seems to work for my use case but maybe there's something wrong about this approach?