Skip to content

Instantly share code, notes, and snippets.

@dimovich
Created September 13, 2018 19:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dimovich/1b8535033d215c19ea6126e73efe44a8 to your computer and use it in GitHub Desktop.
Use same component code for Reagent (client-side) and Hiccup (server-side)
(ns project.common
#?(:cljs (:require [project.util :refer [cc]])))
#?(:clj
(defmacro cc [args]
`(~@args)))
(defn child-component [& opts]
[:div "hello"])
;; is there a way to bypass calling (cc ...) when using
;; [child-component], but still be able to use this function both in
;; cljs and clj ?
(defn parent-component []
[:div
(cc [child-component {:some :opts}])])
(ns project.util)
(defmacro cc [args]
`~args)
(ns project.util
(:require-macros [project.util]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment