Fork me on GitHub
#reagent
<
2015-12-15
>
mikethompson02:12:37

@edvorg: as a general rule, local state is best avoided. BUT, having said that, we use local state quite a bit to hold "mouse-over?" kinda information. But the rule is this: the moment that local state has to be synchronised (the value has to be propogated) outside of the the current component, then local state is almost certainly the wrong option. Look up From-2 components: https://github.com/Day8/re-frame/wiki/Creating-Reagent-Components

mikethompson02:12:04

Perhaps look at re-com for inspiration

mikethompson02:12:14

BTW, nice trick you have: ^{:key @add-button-focus} to force focusing

mikethompson03:12:21

@phil component-did-mount should only fire once. So it is working as expected. Did you want to also provide component-did-update ? This may be of specific interest to you: http://yogthos.net/posts/2015-11-12-ClojureScript-Eval.html and this may be of general interest https://github.com/Day8/re-frame/wiki/Using-Stateful-JS-Components

phil08:12:31

@mikethompson thanks - will give the latter a thorough read.

emil0r23:12:36

nice trick indeed. i'm stealing the idea simple_smile