Last active
June 26, 2024 12:03
-
-
Save roman01la/d1fb72ceb57e5a0200c87e8c59144a4b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns uix.ssr | |
(:require [uix.core :as uix :refer [$ defui]] | |
#?(:cljs ["react-slider" :as react.slider]) | |
#?(:clj [uix.dom.server :as dom.server]))) | |
#?(:cljs | |
(defui js-comp* [{:keys [children]}] | |
(let [[show? set-show] (uix/use-state false)] | |
(uix/use-effect | |
#(set-show true) | |
[]) | |
(when show? children)))) | |
#?(:clj | |
(defmacro js-comp [comp & args] | |
(when (uix.lib/cljs-env? &env) | |
`($ js-comp* ($ ~comp ~@args))))) | |
(defui app [] | |
($ :<> | |
($ :h1 "Hello") | |
(js-comp react.slider/ReactSlider))) | |
#?(:clj | |
(dom.server/render-to-string ($ app))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment