Fork me on GitHub
#rum
<
2017-03-29
>
renewdoit04:03:51

@jeroenvandijk Thanks, it looks like the thing I want

jeroenvandijk07:03:32

@renewdoit just for my understanding, do you mean the global-mixin or the theme approach

renewdoit08:03:39

@jeroenvandijk I am trying to switch a set of components, it is like a theme, but the components itself is different.

jrychter11:03:06

I have a component which performs rather heavy computation based on some of its args. I'm trying to find a way to not perform this computation if these specific args have not changed. Any suggestions? From reading the React docs it seems that componentWillReceiveProps() is where I'd do it, but rum doesn't expose that. Should I use :will-update? Also, I find React docs confusing: "you cannot call this.setState() here" — this doesn't apply to changing rum component state, right?

jimmy12:03:33

I have the same problem, I do check props in :will-update and update rum state via swap! its atom.

jeroenvandijk12:03:52

I’m not a React expert, nor Rum mixin expert, but I’m able to prevent unwanted updates by having several layers of components. So say you have three atoms with three different desired update behaviours, I can imagine you would nest the components or have several components in one

jeroenvandijk12:03:07

For instance, i’m generating a complex form, with multi-staged commits. I’m only able to do this by organising it this way. I’m passing atoms around to do this. Hope this makes sense

rauh12:03:11

@jrychter Does :should-update not do what you want?

jrychter12:03:10

@rauh No, I do want the component to update on every arg change. I just want to avoid the expensive computation that does not depend on all args, so in some cases could be avoided.

jrychter12:03:14

@nxqd Do you mean you swap! the state of a rum/local mixin atom, or the main component state? I thought the main state gets updated when you return it from the mixin fn?

misha12:03:35

@jrychter put computation-result inside another atom, subscribe it to args' change, subscribe component to computation-result-atom change

misha12:03:34

basically extract computation and decision about it out of rum/react

jrychter12:03:16

@misha Thanks, that's interesting and could work…

jimmy12:03:54

@jrychter what I did is exactly what misha wrote above.

misha12:03:55

there is also rum/derived-atom which might help you to reduce amount of boilerplate code