From 6ea9d0400e664d9459d1ab404b283b6179223ccb Mon Sep 17 00:00:00 2001 From: Juho Teperi Date: Fri, 19 Oct 2018 13:01:52 +0300 Subject: [PATCH] Add notes abvout reactify-component alternatives --- .../react-sortable-hoc/src/example/core.cljs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/examples/react-sortable-hoc/src/example/core.cljs b/examples/react-sortable-hoc/src/example/core.cljs index b0bf6f5..91da1ab 100644 --- a/examples/react-sortable-hoc/src/example/core.cljs +++ b/examples/react-sortable-hoc/src/example/core.cljs @@ -8,8 +8,11 @@ (def DragHandle (js/SortableHOC.SortableHandle. - (r/reactify-component - (fn [] [:span "::"])))) + ;; Alternative to r/reactify-component, which doens't convert props and hiccup, + ;; is to just provide fn as component and use as-element or create-element + ;; to return React elements from the component. + (fn [] + (r/as-element [:span "::"])))) (def SortableItem (js/SortableHOC.SortableElement. @@ -19,6 +22,17 @@ [:> DragHandle] value])))) +;; Alternative without reactify-component +;; props is JS object here +#_ +(def SortableItem + (js/SortableHOC.SortableElement. + (fn [props] + (r/as-element + [:li + [:> DragHandle] + (.-value props)])))) + (def SortableList (js/SortableHOC.SortableContainer. (r/reactify-component