Skip to content

Instantly share code, notes, and snippets.

@roman01la
Last active June 26, 2024 12:03
Show Gist options
  • Select an option

  • Save roman01la/d1fb72ceb57e5a0200c87e8c59144a4b to your computer and use it in GitHub Desktop.

Select an option

Save roman01la/d1fb72ceb57e5a0200c87e8c59144a4b to your computer and use it in GitHub Desktop.

Revisions

  1. roman01la revised this gist Jun 26, 2024. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion core.cljs
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,5 @@
    (ns uix.ssr
    (:require [uix.core :as uix :refer [$ defui]]
    #?(:cljs [react :as r])
    #?(:cljs ["react-slider" :as react.slider])
    #?(:clj [uix.dom.server :as dom.server])))

  2. roman01la created this gist Jun 26, 2024.
    26 changes: 26 additions & 0 deletions core.cljs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    (ns uix.ssr
    (:require [uix.core :as uix :refer [$ defui]]
    #?(:cljs [react :as r])
    #?(: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)))