Skip to content

Commit

Permalink
Merge pull request #993 from basics/feature/hydrate-fix
Browse files Browse the repository at this point in the history
fix(hydrate): fix missing negate
  • Loading branch information
ThornWalli authored Apr 27, 2024
2 parents b183e20 + 138569a commit 8a665f7
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 @@ -3,18 +3,18 @@ import { hydrateWhenVisible } from 'vue3-lazy-hydration';
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 8a665f7

Please sign in to comment.