Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/SplitPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ const SplitPane = ({

const wrapSize: number = wrapperRect[sizeName] ?? 0;

const memoizedChildren = useMemo(() => children, [children]);
const memoizedPropSizes = useMemo(() => [...propSizes], [propSizes]);
const memoizedWrapSize = useMemo(() => wrapSize, [wrapSize]);

// Get limit sizes via children
const paneLimitSizes = useMemo(() => children.map(childNode => {
const limits = [0, Infinity];
Expand All @@ -68,7 +72,7 @@ const SplitPane = ({
limits[1] = assertsSize(maxSize, wrapSize);
}
return limits;
}), [children, wrapSize]);
}), [memoizedChildren, memoizedWrapSize]);

const sizes = useMemo(function () {
let count = 0;
Expand All @@ -95,7 +99,7 @@ const SplitPane = ({
}

return res;
}, [...propSizes, children.length, wrapSize]);
}, [memoizedPropSizes, memoizedWrapSize, memoizedChildren]);

const sashPosSizes = useMemo(() => (
sizes.reduce((a, b) => [...a, a[a.length - 1] + b], [0])
Expand Down
2 changes: 1 addition & 1 deletion src/sash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function Sash({
onDragEnd,
...others
}: ISashProps) {
const timeout = useRef<number | null>(null);
const timeout = useRef<NodeJS.Timeout | null>(null);
const [active, setActive] = useState(false);
const [draging, setDrag] = useState(false);

Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export interface ISplitProps extends HTMLElementProps {
export interface ISashProps {
className?: string;
style: React.CSSProperties;
render: (active: boolean) => void;
render: (active: boolean) => React.ReactNode;
onDragStart: React.MouseEventHandler<HTMLDivElement>;
onDragging: React.MouseEventHandler<HTMLDivElement>;
onDragEnd: React.MouseEventHandler<HTMLDivElement>;
Expand Down