Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hydrate never doesn't seem to work #116

Open
hsks opened this issue Oct 11, 2021 · 4 comments
Open

Hydrate never doesn't seem to work #116

hsks opened this issue Oct 11, 2021 · 4 comments

Comments

@hsks
Copy link

hsks commented Oct 11, 2021

Hi,
Thanks for this amazing library.
I was trying this out with nuxt 2.x with hydrate never mode. The code looks something like this:

<LazyHydrate never>
<Component-A>
</LazyHydrate>

Component-A:
<template>
Ssr mode is {{ isSsr }}
</template>

isSsr is a computed property that simply returns the value of process.server.

For some reason, as soon as the page is rendered on the client side, Component A resolves to Ssr mode is false. It works fine when I turn javascript off, which means it's rendered correctly on the server side. I'm using nuxt in universal mode. Any idea how I can prevent hydration of such static components?

@TitanFighter
Copy link

TitanFighter commented Oct 11, 2021

As I understand the default value of isSsr is "false" and as I understand you want to transfer server side value to the client, right? If I remember correctly it wont work. LazyHydrate is a client side tool, this is the reason why you see "false", ie on the client it falls back to the default "false" value.

@hsks
Copy link
Author

hsks commented Oct 12, 2021

Hi,
Thanks for the reply. I agree LazyHydrate works on the client side. But given the never hydrate prop, shouldn't it block any hydration on the client side. This in turn will result is only the server side content rendered -? hence the expected true value.

@TitanFighter
Copy link

I had similar situation long time ago and if I remember correctly I came to the conclusion that: in case of "never" LazyHydrate simply reads default value of variable (as I understand, it is "false" in your case).

@hsks
Copy link
Author

hsks commented Oct 12, 2021

It should be true in any case, since process.server is true during server side rendering. It will only become false if client hydrates the component.
And it seems it has something to do with my app configuration specifically. I just configured a fresh nuxt app and used lazy hydrate, it works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants