Skip to content

Instantly share code, notes, and snippets.

@darkleaf
Created April 21, 2020 12:04
Show Gist options
  • Save darkleaf/cb75364cd6d6f84223e51116520c1ffc to your computer and use it in GitHub Desktop.
Save darkleaf/cb75364cd6d6f84223e51116520c1ffc to your computer and use it in GitHub Desktop.
react interop example
(ns example.core
(:require
[hicada.compiler :as h]))
(defmacro html [body]
(h/compile body {} {} &env))
(ns example.core
(:require
[goog.dom :as dom]
[react :as react]
[react-dom :as react-dom]
[applied-science.js-interop :as j])
(:require-macros
[example.core :refer [html]]))
(j/defn component [^:js {:keys [name children]}]
(html
[:div
[:div name]
[:div children]]))
(react-dom/render
(html
[:*
[:div "foo 5"]
[:> component {:name "John II3"}
[:div "inner 1"]
[:div "inner 2"]]])
(dom/getElement "app"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment