Add notes abvout reactify-component alternatives

This commit is contained in:
Juho Teperi 2018-10-19 13:01:52 +03:00
parent cc69bf479e
commit 6ea9d0400e
1 changed files with 16 additions and 2 deletions

View File

@ -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