Fork me on GitHub
#reagent
<
2016-08-19
>
jm00:08:36

@escherize you can’t use psuedo selectors in inline styles in css. You could have an on-focus handler change the styles passed to the element

timothypratley01:08:53

(or define a class in CSS and put it on the element :)

mikethompson02:08:13

One of these days it would be good to have a reagent equivalent of Radium https://github.com/FormidableLabs/radium

escherize05:08:04

has there been any work in that direction?

martinklepsch07:08:45

@mikethompson do you have an understanding about how radium works? (i.e. how it installs styles etc?)

martinklepsch07:08:29

I'm thinking just having a map with styles and inserting them is straightforward but it gets interesting when you start installing styles dynamically as components using them appear etc

mikethompson07:08:01

Don't know how it works.

mikethompson07:08:46

My wild guess is: 1. It appends its own <style> to body on statup 2. When asked to create a new class dynamically, it hashes it, and compares to all the ones it has previously created. 3. If the hash matches anything previous, it just returns that class name (because it already exists, no need to add it again) 4. If hash does not match anything previously created, then it makes up a new class name, and adds necessary definition to the <style> (see step 1) and returns a class name.

mikethompson07:08:50

Something like that 🙂

Petrus Theron11:08:16

I have a reagent component that takes a value argument, filters: (defn foo [filters] …) It needs to fetch data from an API that depends on filters. So I make a GET request in :component-will-mount. Problem is, after the component is mounted, if the input value of filters changes, ~will-mount is not called. I would expect the component to be remounted whenever its props change, but that is not the case. How should I ensure that my remote data is fetched whenever the input props to my component change?

pesterhazy12:08:56

no it's not re-mounted

pesterhazy12:08:20

you need to listen for :component-did-update as well as to :component-did-mount

pesterhazy12:08:10

additionally, you could check if the props have changed (because it might also be component state, though that's not often used with reagent)

pesterhazy12:08:14

found a bug, updated 🙂

Petrus Theron12:08:16

Yeah, I ended up doing pretty much the same. I didn’t know about r/props tho