New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-virtualized-sticky-tree

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-virtualized-sticky-tree

A React component for efficiently rendering tree like structures with support for position: sticky

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
832
decreased by-31.8%
Maintainers
1
Weekly downloads
 
Created
Source

react-virtualized-sticky-tree

A React component for efficiently rendering tree like structures with support for position: sticky

Getting Started

npm install react-virtualized-sticky-tree --save

Usage

Basic Example

import StickyTree from 'react-virtualized-sticky-tree';

const tree = {
  root: { name: 'Root', children: ['child1', 'child2', 'child3'], depth: 0 },
  child1: { name: 'Child 1', children: ['child4'], depth: 1 },
  child2: { name: 'Child 2', depth: 2 },
  child3: { name: 'Child 3', depth: 2 },
  child4: { name: 'Child 4', depth: 3 },
};

const getChildren = (id) => {
  return tree[id].children;
};

const rowRenderer = (id) => {
  const node = tree[id];
  return <div>{node.name}</div>
};

const getHeight = () => 30;

render(
  <StickyTree
    root="root"
    getChildren={getChildren}
    getHeight={getHeight}
    rowRenderer={rowRenderer}
    renderRoot={true}
    overscanRowCount={20}
  />
);

Dynamic Height Container

If the containing element of your tree has a dynamic height, you can use https://github.com/souporserious/react-measure to provide the width and height to sticky-tree so that it can resize to the available width.

npm install react-measure --save

const MeasuredTree = withContentRect('bounds')(({ measureRef, measure, contentRect }) => (
  <div ref={measureRef} className="sticky-wrapper">
    <StickyTree
      root="root"
      getChildren={getChildren}
      getHeight={getHeight}
      rowRenderer={rowRenderer}
      renderRoot={true}
      width={contentRect.bounds.width}
      height={contentRect.bounds.height}
      overscanRowCount={20}
    />
  </div>
));

Supported Browsers

Rendering tree structures is supported in all modern browsers. position: sticky has only been tested in Chrome 59 and Firefox 54, but should work in Edge, Safari and Opera. See http://caniuse.com/#search=position%3Asticky

Keywords

FAQs

Package last updated on 03 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc