Skip to content

Commit 40b8fae

Browse files
committed
temp clear cache after height change
1 parent c6a8e2a commit 40b8fae

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-fluid-table",
3-
"version": "0.4.7",
3+
"version": "0.4.8",
44
"description": "A React table inspired by react-window",
55
"author": "Mckervin Ceme <mckervinc@live.com>",
66
"license": "MIT",

src/Table.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const ListComponent = forwardRef(
5757
ref: React.ForwardedRef<TableRef>
5858
) => {
5959
// hooks
60+
const heightRef = useRef(-1);
6061
const timeoutRef = useRef(0);
6162
const prevRef = useRef(width);
6263
const cacheRef = useRef<any>({});
@@ -172,6 +173,15 @@ const ListComponent = forwardRef(
172173
// check if we should use the row width when width changes
173174
useEffect(() => shouldUseRowWidth(), [width]);
174175

176+
// every time the height changes, clear the height cache
177+
useLayoutEffect(() => {
178+
if (heightRef.current >= 0 && heightRef.current !== height) {
179+
clearSizeCache(-1, true);
180+
}
181+
182+
heightRef.current = height;
183+
}, [height]);
184+
175185
// manually alter the height of each row if height is incorrect
176186
// to help with flicker on resize
177187
useLayoutEffect(() => {

0 commit comments

Comments
 (0)