react-virtualized-sticky-tree
Version:
A React component for efficiently rendering tree like structures with support for position: sticky
15 lines (14 loc) • 754 B
JavaScript
import React, { useState } from 'react';
import Measure from 'react-measure';
import StickyList from './StickyList.js';
const AutoSizedStickyList = ({ onResize, className, treeRef, ...rest }) => {
const [bounds, setBounds] = useState({});
return (React.createElement(Measure, { bounds: true, onResize: (rect) => {
setBounds({ width: rect.bounds.width, height: rect.bounds.height });
if (onResize !== undefined) {
onResize(rect);
}
} }, ({ measureRef }) => (React.createElement("div", { ref: measureRef, className: className },
React.createElement(StickyList, { treeRef: treeRef, width: bounds.width, height: bounds.height, ...rest })))));
};
export default AutoSizedStickyList;