On 25 jan 2014, at 18:43, David Nolen <[email protected]> wrote: > On Sat, Jan 25, 2014 at 12:34 PM, Jonas Enlund <[email protected]> wrote: > Interesting! I can definitely see how UI components directly manipulating > global state can make reuse difficult. > > I guess this is not really an issue in React as their components have local > state (via getInitialState). It's possible to work with local state in > Reagent as well so reusable components are not completely out of the picture. > > It is an issue if you want modular time management. The undo example for > Reagent is not modular. All time management in Om is designed to work across > any configuration of components embedded in whatever way you please.
Well, that depends on your definition of "modular", doesn't it :) It is "modular" in the sense that it is isolated from the rest of the page, which is (I suppose) sort of the opposite of your idea of modular... Anyway, the typical way to make components reusable in terms of state handling in React is to make parent components responsible for updates and fetches, and pass functions to modify state to children as parameters (e.g remove-contact! and add-contact! in Jonas' example would be local to some parent component, so that children don't have to know anything about state handling). That way you get everything nice and configurable. The downside is some added complexity, and the temptation to make everything so configurable that it becomes unreadable and unusable :) /dan -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
