Use global-exports for react-sortable-hoc example

This commit is contained in:
Juho Teperi 2020-03-28 13:59:11 +02:00
parent ad5475ca1f
commit 83c0cdd698
2 changed files with 6 additions and 7 deletions

View File

@ -3,7 +3,7 @@
[org.clojure/clojurescript "1.10.597"]
[reagent "0.10.0"]
[figwheel "0.5.19"]
[cljsjs/react-sortable-hoc "1.11.0-0"]]
[cljsjs/react-sortable-hoc "1.11.0-1"]]
:plugins [[lein-cljsbuild "1.1.7"]
[lein-figwheel "0.5.19"]]

View File

@ -1,14 +1,13 @@
(ns example.core
(:require [reagent.core :as r]
[reagent.dom :as rdom]
;; FIXME: add global-exports support
[cljsjs.react-sortable-hoc]
[react-sortable-hoc :as sort]
[goog.object :as gobj]))
;; Adapted from https://github.com/clauderic/react-sortable-hoc/blob/master/examples/drag-handle.js#L10
(def DragHandle
(js/SortableHOC.SortableHandle.
(sort/SortableHandle.
;; 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.
@ -16,7 +15,7 @@
(r/as-element [:span "::"]))))
(def SortableItem
(js/SortableHOC.SortableElement.
(sort/SortableElement.
(r/reactify-component
(fn [{:keys [value]}]
[:li
@ -27,7 +26,7 @@
;; props is JS object here
#_
(def SortableItem
(js/SortableHOC.SortableElement.
(sort/SortableElement.
(fn [props]
(r/as-element
[:li
@ -35,7 +34,7 @@
(.-value props)]))))
(def SortableList
(js/SortableHOC.SortableContainer.
(sort/SortableContainer.
(r/reactify-component
(fn [{:keys [items]}]
[:ul