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"] [org.clojure/clojurescript "1.10.597"]
[reagent "0.10.0"] [reagent "0.10.0"]
[figwheel "0.5.19"] [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"] :plugins [[lein-cljsbuild "1.1.7"]
[lein-figwheel "0.5.19"]] [lein-figwheel "0.5.19"]]

View File

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