Skip to content

Commit

Permalink
Merge pull request #324 from inokawa/swr-minify
Browse files Browse the repository at this point in the history
Fix swr minify issue in Next.js
  • Loading branch information
inokawa authored Jan 12, 2024
2 parents bf1f13b + f348a58 commit 82e14a0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/core/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export const createVirtualStore = (
elementsCount: number,
itemSize: number = 40,
ssrCount: number = 0,
cache: Cache = initCache(elementsCount, itemSize),
cacheSnapshot?: CacheSnapshot | undefined,
shouldAutoEstimateItemSize?: boolean | undefined,
startSpacerSize: number = 0,
endSpacerSize: number = 0
Expand All @@ -195,6 +195,8 @@ export const createVirtualStore = (
: null;
let _prevRange: ItemsRange = [0, 0];

const cache =
(cacheSnapshot as Cache | undefined) || initCache(elementsCount, itemSize);
const subscribers = new Set<[number, Subscriber]>();
const getTotalSize = (): number => computeTotalSize(cache);
const getScrollableSize = (): number =>
Expand Down
3 changes: 1 addition & 2 deletions src/react/Virtualizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { useLatestRef } from "./useLatestRef";
import { createResizer } from "../core/resizer";
import { ListItem } from "./ListItem";
import { CacheSnapshot, ScrollToIndexOpts } from "../core/types";
import { Cache } from "../core/cache";
import { flushSync } from "react-dom";
import { useRerender } from "./useRerender";
import { useChildren } from "./useChildren";
Expand Down Expand Up @@ -208,7 +207,7 @@ export const Virtualizer = forwardRef<VirtualizerHandle, VirtualizerProps>(
count,
itemSize,
ssrCount,
cache as unknown as Cache | undefined,
cache,
!itemSize,
startMargin,
endMargin
Expand Down
3 changes: 1 addition & 2 deletions src/react/WindowVirtualizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { createWindowResizer } from "../core/resizer";
import { CacheSnapshot } from "../core/types";
import { CustomContainerComponent, CustomItemComponent } from "./types";
import { ListItem } from "./ListItem";
import { Cache } from "../core/cache";
import { flushSync } from "react-dom";
import { useRerender } from "./useRerender";
import { useChildren } from "./useChildren";
Expand Down Expand Up @@ -151,7 +150,7 @@ export const WindowVirtualizer = forwardRef<
count,
itemSize,
ssrCount,
cache as unknown as Cache | undefined,
cache,
!itemSize
);

Expand Down

0 comments on commit 82e14a0

Please sign in to comment.