This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-19
Channels
- # beginners (34)
- # boot (111)
- # cider (37)
- # clara (57)
- # cljsjs (1)
- # cljsrn (22)
- # clojure (156)
- # clojure-austin (2)
- # clojure-mke (7)
- # clojure-russia (9)
- # clojure-spec (221)
- # clojure-uk (47)
- # clojurescript (42)
- # code-reviews (4)
- # community-development (9)
- # core-async (3)
- # cursive (50)
- # datomic (81)
- # emacs (12)
- # events (5)
- # hoplon (1)
- # jobs (2)
- # lein-figwheel (4)
- # leiningen (1)
- # luminus (3)
- # mount (2)
- # off-topic (1)
- # om (94)
- # om-next (3)
- # onyx (33)
- # re-frame (23)
- # reagent (41)
- # remote-jobs (9)
- # rum (30)
- # slack-help (2)
- # specter (1)
- # untangled (20)
- # yada (17)
I was loooking at reforms, and I’m not prepared to bring on a whole library for one input text field
I was able to use a combo of defcs
and rum/local
to hold local state for the form input.
I usually keep two states: “dirty” state that is directly displayed in input, and cleaned value that is reported to the global model/parent component/etc. Former is kept in rum/local. Latter is not filled until validation passes. That’s the gist of it
I am trying to define a layout like so:
(rum/defc layout [ & {:keys [title head body]}]
;; <!DOCTYPE html>
[:html
[:head
[:meta {:charset "UTF-8"}]
[:meta {:name "viewport" :content "width=device-width, initial-scale=1"}]
[:link {:href "css/style.css" :rel "stylesheet" :type "text/css"}]
[:link {:href "cljsjs/semantic-ui/semantic.min.css" :rel "stylesheet" :type "text/css"}]]
[:body
[:#app]
[:script {:src "js/compiled/wlister.js" :type "text/javascript"}]]])
2. I need somehow to combine render-static-markup
for external html layout and render-html
rum call for components. Not sure how to do that
aha. I guess I just insert the call inside render-static-markup with dangerouslySetInnerHTML... =/
(rum/defc layout [body] ;[ & {:keys [title head body]}]
[:html
[:head
[:meta {:charset "UTF-8"}]
[:meta {:name "viewport" :content "width=device-width, initial-scale=1"}]
[:link {:href "css/style.css" :rel "stylesheet" :type "text/css"}]
[:link {:href "cljsjs/semantic-ui/semantic.min.css" :rel "stylesheet" :type "text/css"}]]
[:body
[:#app {:dangerouslySetInnerHTML {:__html (rum/render-html (body))}}]
[:script {:src "js/compiled/wlister.js" :type "text/javascript"}]]])
(I don't have vim repl multiplexer for cljc - when I eval in files, it's either server or figwheel. for cljc it's always server and I guess I need to reprogram vim-fireplace somehow. yay)
yes, the layout above did work with basic components. It does produce html layout without data-react checksums and then div#app with server-side rendered react component
can I ask stupid question? ok, so suppose I have a component which is a table. with one column - date. in browser I just display it with local formatting based on browser locale. during server-side rendering, what am I supposed to do to make react overwrite this component during client-side mount?
the downside, of course, is that user can see the moment when server markup will change into client one. There might me a significant gap in time (couple of seconds)