Skip to content

Commit

Permalink
fix(hydrate): revert hydrate
Browse files Browse the repository at this point in the history
  • Loading branch information
ThornWalli committed Apr 29, 2024
1 parent 2783caf commit 29647c7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/runtime/hydrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import { defineAsyncComponent, useRuntimeConfig } from '#imports';
const isDev = process.env.NODE_ENV === 'development';

export default component => {
if (isDev || import.meta.server) {
if (typeof component === 'function') {
component = defineAsyncComponent(component);
}
return component;
}

const runtimeConfig = useRuntimeConfig();

return hydrateWhenVisible(component, {
return hydrateWhenVisible(wrapComponent(component), {
observerOptions: {
rootMargin: runtimeConfig.public.booster.lazyOffsetComponent || '0%'
}
});
};

const wrapComponent = component => {
if (!(isDev || import.meta.server) && typeof component === 'function') {
return defineAsyncComponent(component);
}
return component;
};

0 comments on commit 29647c7

Please sign in to comment.