|
5 | 5 | [reagentdemo.syntax :as s] |
6 | 6 | [sitetools.core :refer [link]] |
7 | 7 | [reagentdemo.common :as common :refer [demo-component]] |
| 8 | + [reagentdemo.solutions :as solutions] |
8 | 9 | [simpleexample.core :as simple] |
9 | 10 | [todomvc.core :as todo])) |
10 | 11 |
|
|
110 | 111 |
|
111 | 112 |
|
112 | 113 | (defn intro [] |
113 | | - (let [github {:href "https://github.com/reagent-project/reagent"} |
114 | | - clojurescript {:href "https://github.com/clojure/clojurescript"} |
115 | | - react {:href "http://facebook.github.io/react/"} |
116 | | - hiccup {:href "https://github.com/weavejester/hiccup"} |
| 114 | + (let [github {:href "https://github.com/reagent-project/reagent"} |
| 115 | + clojurescript {:href "https://github.com/clojure/clojurescript"} |
| 116 | + react {:href "http://facebook.github.io/react/"} |
| 117 | + hiccup {:href "https://github.com/weavejester/hiccup"} |
117 | 118 | dynamic-children {:href "http://facebook.github.io/react/docs/multiple-components.html#dynamic-children"}] |
118 | 119 | [:div.demo-text |
119 | 120 |
|
120 | 121 | [:h2 "Introduction to Reagent"] |
121 | 122 |
|
122 | 123 | [:p [:a github "Reagent"] " provides a minimalistic interface |
123 | | - between " [:a clojurescript "ClojureScript"] " and " [:a |
124 | | - react "React"] ". It allows you to define efficient React |
| 124 | + between " [:a clojurescript "ClojureScript"] " and " |
| 125 | + [:a react "React"] ". It allows you to define efficient React |
125 | 126 | components using nothing but plain ClojureScript functions and |
126 | 127 | data, that describe your UI using a " [:a hiccup "Hiccup"] "-like |
127 | 128 | syntax."] |
|
132 | 133 | about performance."] |
133 | 134 |
|
134 | 135 | [:p "A very basic Reagent component may look something like this: "] |
135 | | - [demo-component {:comp simple-component |
136 | | - :src (s/src-of [:simple-component])}] |
| 136 | + [demo-component {:expected simple-component |
| 137 | + :comp solutions/simple-component |
| 138 | + :src (s/src-of [:simple-component])}] |
137 | 139 |
|
138 | 140 | [:p "You can build new components using other components as |
139 | 141 | building blocks. Like this:"] |
140 | 142 | [demo-component {:comp simple-parent |
141 | | - :src (s/src-of [:simple-parent])}] |
| 143 | + :src (s/src-of [:simple-parent])}] |
142 | 144 |
|
143 | 145 | [:p "Data is passed to child components using plain old Clojure |
144 | 146 | data types. Like this:"] |
145 | 147 |
|
146 | 148 | [demo-component {:comp say-hello |
147 | | - :src (s/src-of [:hello-component :say-hello])}] |
| 149 | + :src (s/src-of [:hello-component :say-hello])}] |
148 | 150 |
|
149 | 151 | [:p [:strong "Note: "] |
150 | 152 | "In the example above, " [:code "hello-component"] " might just |
|
156 | 158 | be called with square brackets."] |
157 | 159 |
|
158 | 160 | [:p "Here is another example that shows items in a " |
159 | | - [:code "seq"] ":" ] |
| 161 | + [:code "seq"] ":" ] |
160 | 162 |
|
161 | 163 | [demo-component {:comp lister-user |
162 | | - :src (s/src-of [:lister :lister-user])}] |
| 164 | + :src (s/src-of [:lister :lister-user])}] |
163 | 165 |
|
164 | 166 | [:p [:strong "Note: "] |
165 | | - "The " [:code "^{:key item}"] " part above isn’t really necessary |
| 167 | + "The " [:code "^{:key item}"] " part above isn’t really necessary |
166 | 168 | in this simple example, but attaching a unique key to every item |
167 | 169 | in a dynamically generated list of components is good practice, |
168 | 170 | and helps React to improve performance for large lists. The key |
169 | 171 | can be given either (as in this example) as meta-data, or as a " |
170 | | - [:code ":key"] " item in the first argument to a component (if it |
| 172 | + [:code ":key"] " item in the first argument to a component (if it |
171 | 173 | is a map). See React’s " [:a dynamic-children "documentation"] " |
172 | 174 | for more info."]])) |
173 | 175 |
|
|
0 commit comments