Skip to content

Instantly share code, notes, and snippets.

@dimovich
Created Sep 13, 2018
Embed
What would you like to do?
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