Hi. Has anyone tried Server Side Rendering with , untangled routing ?
router-instruction & routing-tree-key seem to be missing in the clj file.
for (uc/get-initial-state TopRouter {}) I get No implementation of method: :initial-state of protocol: #'untangled.client.core/InitialAppState
Am I doing something wrong or is it not designed for server side rendering ?
@claudiu I believe there’s a function get-initial-state
to deal with calling static methods on the server.
@gardnervickers yep. Seem to work for normal components. But for defrouter or components that have defrouter (the macro from https://untangled-web.github.io/untangled/guide.html#!/untangled_devguide.M15_Routing_UI)
Looks like the router uses get-inital-state
, that’s not working for you?
worked like a charm for cljs 🙂 but in clojure seems to break
re-writing without the defrouter for now (like in the routing getting started video), since that seems to be the problem as far as I can tell.
Are you sure you’re not calling initial-state
anywhere?
ohh, you’re right. Don’t exactly what I did wrong but seems like if I remove a more complex component it works.
@gardnervickers thank you, all working now. Was calling uc/initial-state Component {}
instead of uc/get-initial-state, strangely enough clojurescript app was working just fine.
@claudiu calling the protocol method directly does work in cljs, but it cannot work on the JVM, which is why we provide the additional funciton
Javascript lets you dynamically change a class in a way that works for that. JVM does not.
The syntax on defui (static protocols) is like saying “I want static methods on a class, but I want them to conform to an interface”…the JVM does not have such a thing. Neither does js, but it is dynamic and can fake it
@tony.kay cool. Fooled me a bit, since I did not pay close attention there knowing that it worked in cljs 🙂