Update create-class doc strings

This commit is contained in:
Juho Teperi 2018-12-31 15:04:10 +02:00
parent 91b134aabb
commit b4789ed0f5
2 changed files with 13 additions and 4 deletions

View File

@ -103,8 +103,7 @@
(batch/flush-after-render))
(defn create-class
"Create a component, React style. Should be called with a map,
looking like this:
"Creates JS class based on provided Clojure map, for example:
```cljs
{:get-initial-state (fn [this])
@ -118,7 +117,13 @@
:reagent-render (fn [args....])} ;; or :render (fn [this])
```
Everything is optional, except either :reagent-render or :render."
Everything is optional, except either :reagent-render or :render.
Map keys should use `React.Component` method names (https://reactjs.org/docs/react-component.html),
and can be provided in snake-case or camelCase.
Constructor function is defined using key `:get-initial-state`.
React built-in static methods or properties are automatically defined as statics."
[spec]
(comp/create-class spec))

View File

@ -98,6 +98,9 @@
[c]
(let [f (.-reagentRender c)
_ (assert-callable f)
;; cljsLegacyRender tells if this calls was defined
;; using :render instead of :reagent-render
;; in that case, the :render fn is called with just `this` as argument.
res (if (true? (.-cljsLegacyRender c))
(.call f c c)
(let [v (get-argv c)
@ -284,7 +287,8 @@
(defn create-class
"Creates JS class based on provided Clojure map.
Map keys should use `React.Component` method names (https://reactjs.org/docs/react-component.html).
Map keys should use `React.Component` method names (https://reactjs.org/docs/react-component.html),
and can be provided in snake-case or camelCase.
Constructor function is defined using key `:getInitialState`.
React built-in static methods or properties are automatically defined as statics."