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)) (batch/flush-after-render))
(defn create-class (defn create-class
"Create a component, React style. Should be called with a map, "Creates JS class based on provided Clojure map, for example:
looking like this:
```cljs ```cljs
{:get-initial-state (fn [this]) {:get-initial-state (fn [this])
@ -118,7 +117,13 @@
:reagent-render (fn [args....])} ;; or :render (fn [this]) :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] [spec]
(comp/create-class spec)) (comp/create-class spec))

View File

@ -98,6 +98,9 @@
[c] [c]
(let [f (.-reagentRender c) (let [f (.-reagentRender c)
_ (assert-callable f) _ (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)) res (if (true? (.-cljsLegacyRender c))
(.call f c c) (.call f c c)
(let [v (get-argv c) (let [v (get-argv c)
@ -284,7 +287,8 @@
(defn create-class (defn create-class
"Creates JS class based on provided Clojure map. "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`. Constructor function is defined using key `:getInitialState`.
React built-in static methods or properties are automatically defined as statics." React built-in static methods or properties are automatically defined as statics."