Newbie modelling question here. The general question is do I have multiple instances of the same component configured differently or a single instance which is parameterisable?
I have a SPA with a set of sub "pages". Each sub-page has a banner at the top. This banner displays the title but it might also display sub-page specific information. For example, the search page will display a summary of results in the banner, which when clicked on does something. The project-list sub-page will display any outstanding projects which when clicked on does something else. Essentially the "banner" might be fundamentally different between sub-pages". In other words, when looking at the welcome page I want this: - page -- banner --- title: "Welcome" On the search page: - page -- banner --- title: "Search results" --- SearchResultsBannerComponent On the project page: - page -- banner --- title: "Projects" --- ProjectBannerComponent In direct-dom-manipulation world I would replace the banner div on navigation. In react world I can see three approaches: 1) a single instance of banner which knows how it is used everywhere. One of the configuration parameters must be a component itself (or resolvable to a component through dynamic dispatch) 2) each sub-page is a component hierarchy each including their own configuration of the banner component. So three pages, three instances of the banner. Each sub-page lives in the dom but only one is visible at any one time (display: none for example) 3) like 2 but the component hierarchy is rebuilt upon navigation. I really hope it isn't 1 as that (unless I misunderstand) is quite restrictive. I can see Clojure's fantastically flexible dispatching capability helping but it still seems the wrong way to chunk concerns. 2 or 3 seem to be the same approach - multiple component hierarchies, choosing 2 or 3 is a matter of style? 2 or 3 would work with something dispatching on the ":current-sub-page", the result of which is the appropriate hierarchy. In fact, 3 seems the most "idiomatic" way forward, replying on the efficiency of the diff'ing technique - not sure. The trouble is I have seen examples of all three :). I don't know what option 4 is but I am sure it exists. Help :). -- 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.
