Skip to content

Commit

Permalink
Fix incorrect binding to portal function
Browse files Browse the repository at this point in the history
  • Loading branch information
niwinz committed Dec 10, 2024
1 parent 0016623 commit 28783a7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
2 changes: 2 additions & 0 deletions examples/rumext/examples/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[rumext.examples.local-state :as local-state]
[rumext.examples.refs :as refs]
[rumext.examples.controls :as controls]
[rumext.examples.portals :as portals]
[rumext.examples.board :as board]
;; [rumext.examples.errors :as errors]
))
Expand All @@ -17,6 +18,7 @@
(refs/mount!)
(controls/mount!)
(board/mount!)
(portals/mount!)

(defn main
[& args]
Expand Down
39 changes: 22 additions & 17 deletions examples/rumext/examples/portals.cljs
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
(ns rumext.examples.portals
#_(:require [rumext.core :as mx]
[rumext.examples.util :as util]))
(:require
[rumext.v2 :as mf]
[goog.dom :as dom]))

;; (mx/defc portal
;; [*clicks]
;; [:div {:on-click (fn [_] (swap! *clicks inc))
;; :style { :user-select "none", :cursor "pointer" }}
;; "[ PORTAL Clicks: " @*clicks " ]"])
(mf/defc portal*
{::mf/props :obj}
[{:keys [state]}]
[:div {:on-click (fn [_] (swap! state inc))
:style { :user-select "none", :cursor "pointer" }}
"[ PORTAL Clicks: " @state " ]"])

(mf/defc portals*
[]
(let [state (mf/use-state 0)]
[:div {:on-click (fn [_] (swap! state inc))
:style { :user-select "none", :cursor "pointer" }}
"[ ROOT Clicks: " @state " ]"
(mf/portal
(mf/html [:> portal* {:state state}])
(dom/getElement "portal-off-root"))]))

;; (mx/defcs portals
;; {:mixins [(mx/local 0 ::*clicks)]}
;; [{*clicks ::*clicks}]
;; [:div {:on-click (fn [_] (swap! *clicks inc))
;; :style { :user-select "none", :cursor "pointer" }}
;; "[ ROOT Clicks: " @*clicks " ]"
;; (mx/portal (portal *clicks) (util/el "portal-off-root"))])
(defonce root
(mf/create-root (dom/getElement "portals")))


;; (defn mount! [el]
;; (mx/mount (portals) el))
(defn ^:after-load mount! []
(mf/render! root (mf/element portals*)))
2 changes: 1 addition & 1 deletion src/rumext/v2.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(:require-macros [rumext.v2 :refer [defc fnc]])
(:require
["react" :as react]
["react-dom/client" :as rdom]
["react-dom" :as rdom]
["react/jsx-runtime" :as jsxrt]
[cljs.core :as c]
[goog.functions :as gf]
Expand Down
2 changes: 1 addition & 1 deletion src/rumext/v2/compiler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

(def default-handlers
{:> (fn [& [_ tag props :as children]]
(when (> 3 (count children))
(when (> 2 (count children))
(throw (ex-info "invalid params for `:>` handler, tag and props are mandatory"
{:params children})))

Expand Down

0 comments on commit 28783a7

Please sign in to comment.