diff --git a/src/reagent/core.cljs b/src/reagent/core.cljs index ae0ff16..98da883 100644 --- a/src/reagent/core.cljs +++ b/src/reagent/core.cljs @@ -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)) diff --git a/src/reagent/impl/component.cljs b/src/reagent/impl/component.cljs index 114e287..ed92bf4 100644 --- a/src/reagent/impl/component.cljs +++ b/src/reagent/impl/component.cljs @@ -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."