Fork me on GitHub
#reagent
<
2017-05-16
>
cl0jurian09:05:50

Hi there, is it good practice to use jQuery DOM manipulations within react ?

pesterhazy09:05:36

React likes to reign sovereign over the dom, or the part that it renders in

pesterhazy09:05:06

If you change DOM attributes directly (not going through React), you're asking for trouble

cl0jurian11:05:43

pesterhazy: I afraid so. thank you.

cl0jurian18:05:00

Hi @pesterhazy I got another issue with my code. How do I change a css class of the same react element onclick?

cl0jurian18:05:15

as u suggest earlier, I used the ratom swap! approach to class name. But my need only success if I call force-update-all.

cl0jurian18:05:22

But I cannot employ that method because it brings disaster.

pesterhazy19:05:25

There must be a mistake in your code

cl0jurian19:05:45

thank you very much ! my silly mistake was using the cljs atom instead of reagent atom.

pesterhazy07:05:41

no problem, that happens easily

pesterhazy09:05:38

The things you're doing -- adding or removing classes -- is exactly what React is for

pesterhazy09:05:24

what you should do instead is to make the classes of the element you're updating conditional on the current value of a ratom

pesterhazy09:05:50

then on click, swap the atom

pesterhazy09:05:12

React is a different way to think about the DOM, but once it "clicks", it should become natural to you.

practicalli-johnny10:05:31

I am running a list comprehension with for over a vector of maps from the app-state, however it seems that each map is being returned as a vector. Is this normal behaviour? To make it return a map I have used (apply hash-map talk) where talk is each element from the vector. I want to show a series of talks details from a conference - code is in this gist if it helps https://gist.github.com/35f58e42ae1df3269261436b667a273c

Geoffrey Gaillard15:05:53

I'm dealing with a strange behaviour with reagent. If I have an [:input {:type :text}] that swap! a ratom when the value change with :on-change, then the keys composition, mostly accents (like êâãï …) is ignored. Instead I get ^e^a~a¨i. Did some of you encountered it ?

talgiat17:05:49

can I call reagent/render twice each one with a different root and different view? For some reason the last render removes the previous one.

pesterhazy18:05:28

wait, you render a component at the same DOM node twice? Yes, then the second render overrides the first. What would you expect to happen?

pesterhazy18:05:11

@ggaillard try printing out the events as you receive them using console.log. What does it show?

cl0jurian18:05:00

Hi @pesterhazy I got another issue with my code. How do I change a css class of the same react element onclick?

cl0jurian18:05:22

But I cannot employ that method because it brings disaster.

dfcarpenter19:05:41

Hi everyone, i'm curious how people are writing tests for their reagent components. On googling, resources seem outdated or scarce. Any testing setups or workflows that people can share that they have had success with?

gadfly36119:05:15

@dfcarpenter i generally only write unit tests and do so with lein-doo and cljs.test

gadfly36119:05:32

Wrote a few testing recipes in reagent-cookbook which includes react tests utils and test.check. for unit tests tho, a quick start would be lein new reagent-figwheel myapp +test

dfcarpenter19:05:13

@gadfly361 Thanks, ill look into that