Fork me on GitHub
#reagent
<
2016-10-14
>
mathpunk21:10:23

I have some experience using React from ES6. Now I'm trying reagent. It's going well only, now I'm trying to use material-ui components and I'm not sure how to approach their use of local state.

mathpunk21:10:12

Currently I'm staring at the "Expandable example" here http://www.material-ui.com/#/components/card

mathpunk21:10:32

So far all the components I've made have been pure functions or used my app's main state atom

mathpunk21:10:50

Help understanding props & state in reagent would be appreciated. Searching reagent docs now....

mathpunk22:10:31

I guess what I'm not clear on is whether I'm supposed to get at a state attribute defined by their component, or whether i'm supposed to manage that state by keeping it in my main atom (or some atom local to the component I'm making out of material-ui components)

gadfly36122:10:14

@mathpunk Reagent generally puts all state into atoms. Whether you use just one or several comes down to preference. My preference is to shove everything into a single atom and then use cursors whenever reading from or writing to that atom.

mathpunk22:10:11

@gadfly361: hmmm, so like..... if in JSX something looks like <Card expanded={this.state.expanded} />, I should have something akin to [Card {:expanded @some-path-inside-an-atom}]

mathpunk22:10:34

I thought it was Om that used cursors not Reagent, but I'm thinking you mean more of a pattern

mathpunk22:10:58

like, (get-in @state [:some :path :to :data]) maybe