This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-28
Channels
- # asami (5)
- # babashka (44)
- # beginners (22)
- # biff (7)
- # clerk (86)
- # clj-kondo (5)
- # clojure (33)
- # clojure-europe (8)
- # clr (6)
- # community-development (2)
- # fulcro (20)
- # graalvm (5)
- # graphql (1)
- # hugsql (3)
- # integrant (5)
- # java (11)
- # joyride (2)
- # leiningen (4)
- # malli (12)
- # nbb (15)
- # off-topic (28)
- # pathom (23)
- # reitit (8)
- # releases (1)
- # sci (6)
- # shadow-cljs (39)
- # tools-deps (15)
- # tree-sitter (1)
(def root (. js/document -getElementById "root"))
TypeError: fexpr__12271 is undefined
not relevant
but figured out issue
wrong syntax should have been (def root-div (.getElementById js/document "root"))
how to pass multiple parameters
(.render mithril/m root-div "hi")
original is
m.render(root-div, "Hello world")
that's mistaken should not have both
m is just mithril should be mithril/render
got it running
mithril with clojurescript is kino
How to call m("h1", "header")?
m("h1" "header") doesn't seem to work
w00t ty
(m/render (.body js/document)
(m "h1" "my epic win")
(m "h2" "test")
(m "button" "an epic button")))
whycome TypeError: document.body is not a function
I understand conceptually that I'm calling function instead of getting object but idk how to get object
I don't think aget is what supposed to use
(. js/document -body) return nil
DOM element being rendered to does not exist.
w00ty
figured it out I think desu
one moment plz
Writing a hook(?) works DOM needs to load first Not sure if this is a bloated solution?
(ns
(:require [mithril :as m]))
(defn render-content []
(println "test rendering")
(println(. js/document -body))
(m/render (. js/document -body)
(m "h1" "my epic header")))
(defn init []
;; tests
(println "hello world")
;; renders
(.addEventListener js/document "DOMContentLoaded" render-content))
How to represent something of the form
m("main", [
m("h1", {class: "title"}, "My first app"),
m("button", "A button"),
])
(array []?)hmm something of the form
(defn render-content []
(println "test rendering")
(println(. js/document -body))
(m/render (. js/document -body) (m "h1" "test"
(m "h1" "my epic header")
(m "h2" "my epic subheader"))))
works
but idk why(m "h1" #js {:class "test"} "my epic header") and #js needed to communicate its json object and not a map (just in case this helps anyone ^^