Fork me on GitHub
#rum
<
2020-06-17
>
sova-soars-the-sora14:06:00

I have a question about rum/hydrate... it can add functionality to my components that were rendered from the server... so if the component is rendered on the server and then the client hydrates it ... it can override it with the client definition? (the client has {:on-click (code)} for example that would then get loaded?

sova-soars-the-sora14:06:09

I'm wondering if I need 1:1 data representation between the server and the client or if the server-side rendered page with data is enough to send over the wire... and then load only updates

sova-soars-the-sora15:06:27

how can I include a vanilla js function in my rum code?

sova-soars-the-sora16:06:01

😄 thanks nevermind... interop.

sova-soars-the-sora19:06:11

Warning: Expected server HTML to contain a matching <div> in <div>.

sova-soars-the-sora19:06:35

how can i ensure the client sees the same div, it seems like matching key-fn doesn't do it...

sova-soars-the-sora20:06:21

so yeah... not sure how to make sure rum/hydrate finds the correct components. the example in the guide is too minimal for me to understand what i'm doing wrong ;-;

Jan K20:06:03

it's the same as mounting the component, only hydrate expect the DOM subelements already present

sova-soars-the-sora20:06:34

On the server I am using rum/render-html maybe that is why?

sova-soars-the-sora20:06:51

thanks i will take a look...

sova-soars-the-sora20:06:39

do serverside and clientside HTML need to be identical? or just the component i am hydrating?

Jan K20:06:24

rum/render-html is the way to go, you just have to render the same DOM as the client would

Jan K20:06:51

the component has to be identical

sova-soars-the-sora20:06:48

I think the issue is where I am mounting it. I think I am mounting to a div that is actually a child component...

sova-soars-the-sora20:06:15

rum/render-html spits out html but does not require a div to mount something on

sova-soars-the-sora21:06:14

@jkr.sw thanks bruv! "<div id='rhaq'>" (rum/render-html (all-question-page rk-set)) "</div>" (rum/hydrate (all-question-page in-data) (.getElementById js/document "rhaq"))

Jan K21:06:09

@sova You can also do (rum/render-html [:div#rhaq (all-question-page rk-set)])