-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
example of how this works with rum? #10
Comments
You need to use the fully qualified ns in the example, I tested it out on the example project like this: diff --git a/basic-deps-cljs/deps.edn b/basic-deps-cljs/deps.edn
index 6bcb0a6..ce547b9 100644
--- a/basic-deps-cljs/deps.edn
+++ b/basic-deps-cljs/deps.edn
@@ -1,5 +1,5 @@
{:paths ["src"]
- :deps {reagent/reagent {:mvn/version "0.8.1"}}
+ :deps {rum/rum {:mvn/version "0.11.4"}}
:aliases {:docs {:extra-deps {dynadoc/dynadoc {:mvn/version "RELEASE"}
org.clojure/clojurescript {:mvn/version "1.10.764"}
com.bhauman/figwheel-main {:mvn/version "0.2.11"}}
diff --git a/basic-deps-cljs/src/basic_deps_cljs/core.cljs b/basic-deps-cljs/src/basic_deps_cljs/core.cljs
index 9f332cb..f7ec73e 100644
--- a/basic-deps-cljs/src/basic_deps_cljs/core.cljs
+++ b/basic-deps-cljs/src/basic_deps_cljs/core.cljs
@@ -1,18 +1,16 @@
(ns basic-deps-cljs.core
- (:require [reagent.core :as r]
+ (:require [rum.core :as rum]
[goog.object :as gobj])
(:import goog.net.XhrIo))
-(defn clicks
- "Shows the number of times the user clicked the button."
- [button-text]
- (let [state (r/atom {:clicks 0})]
- (fn []
- [:div
- [:p "You clicked " (:clicks @state) " times"]
- [:button {:on-click (fn []
- (swap! state update :clicks inc))}
- button-text]])))
+(rum/defcs clicks < (rum/local 0 ::count)
+ [state button-text]
+ (let [*count (::count state)]
+ [:div
+ [:p "You clicked " @*count " times"]
+ [:button {:on-click (fn []
+ (swap! *count inc))}
+ button-text]]))
(defn get-lib-version
"Queries Clojars for the version of the given library, providing it in a
diff --git a/basic-deps-cljs/src/basic_deps_cljs/docs.cljs b/basic-deps-cljs/src/basic_deps_cljs/docs.cljs
index 683c8e9..0d149f8 100644
--- a/basic-deps-cljs/src/basic_deps_cljs/docs.cljs
+++ b/basic-deps-cljs/src/basic_deps_cljs/docs.cljs
@@ -6,9 +6,8 @@
(defexample basic-deps-cljs.core/clicks
{:with-card card
- :with-focus [focus [clicks "Click me!"]]}
- (reagent.core/unmount-component-at-node card)
- (reagent.core/render-component focus card)
+ :with-focus [focus (clicks "Click me!")]}
+ (rum.core/mount focus card)
nil) |
That worked for me, thanks for the example! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm assuming this will play nice with rum.
I wasn't able to follow the code in the defexample macro, so I'm not sure what arguments it takes in full. My example so far looks like this:
And on the dynadoc page, which renders fine (I'm back to using figwheen atm), it's saying "rum.mount is not a function" on the page. Which I'm not sure how to understand, as it's certainly is one according to the rum docs.
The text was updated successfully, but these errors were encountered: