Fork me on GitHub
#reagent
<
2017-01-23
>
artur08:01:22

Is there an easy way to convert from reagent server version to reagent-frontend version?

gadfly36108:01:55

@artur just trying to get clarification to your question. It sounds like you are referring to the two reagent-project templates. If not, have you seen this? https://github.com/reagent-project/reagent-frontend-template

gadfly36108:01:43

In any case, unfortunately cant provide guidance on how to migrate an existing app. But if you havent seen that, it's a good place to start

artur08:01:08

What I have done is created an app with the server version of the reagent template but really wanted the front-end template version since all I want is deploy single js file.

artur08:01:39

I might just create new with reagent-frontend-template and move the src stuff to that

gadfly36108:01:20

Yeah probably a good idea. The cljs source should be about the same. By using the frontend template you'll blast the clj source and add an index.html file and dramatically reduce the size of your project.clj file

artur08:01:41

My point exactly since I host the project with nginx

artur08:01:51

Thanks for your help!

artur12:01:35

It works, just FYI

artur17:01:29

I have a problem with reagent component and reagent atom.

artur17:01:19

I have a component which I want to render which includes a button and when I click on it, I want to update that component's state. For some reason, when I click on the button, the render function of the component is called again but only once. If I click on the button again it doesn't call the render function any more. Second problem: If I render this component multiple times and click on one button, the state is the same on all buttons instead of just one. Am I missing something?

metametadata19:01:56

@artur 1) the component is re-rendered once because the ratom is not changed the second time the button is clicked (it's already set to "Foo") 2) if all your components deref the same global ratom than it's an expected behavior I guess

Pablo Fernandez21:01:48

Any ideas how to write this in Reagent: return <RTListItem caption={props.title} rightActions={rightActions} />; This is the context: https://github.com/Podlas29/todoy/blob/f47f3e82bfccdbfb47487b5b2f124c31261b6c59/src/front/components/List/ListItem.tsx#L17

Pablo Fernandez21:01:19

It's an array with a react component in it. I tried [[rt/icon-button {:id "button" :icon "refresh"}]] but I get this error: js_dependencies.js:283 Uncaught Invariant Violation: Objects are not valid as a React child (found: object with keys {name, id, class}). If you meant to render a collection of children, use an array instead or wrap the object using createFragment(object) from the React add-ons. Check the render method of ListItemActions.

pesterhazy22:01:50

@pupeno, (r/as-element [:> js/RTListIte {:caption ... :right-actions ...}])

richiardiandrea23:01:18

I started to use r/track a lot, kind of following composable subscriptions in re-frame, it was a very good addition thanks!

pesterhazy23:01:25

I use it frequently as well!

richiardiandrea23:01:27

@pesterhazy I am kind of new to it and I wonder if this is good usage:

(defn get-relationships [state]
  ..fetch relationships from state...))

(defn get-indexed-relationships [state]
  (let [rels @(r/track get-relationships state)]
   ...create index...
    ))

pesterhazy23:01:18

looks good to me

richiardiandrea23:01:32

thanks for confirming