
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
react-treeviewselect
Advanced tools
A react based select control where the drop down is a tree view.
React/JS is not my first language, so open to suggestions for improvements as I have not seen a useful version of this control elsewhere, so I want this to be robust.
yarn add react-treeviewselect
or
npm install react-treeviewselect --save
import { TreeViewSelect } from "react-treeviewselect";
function renderManagerLink(manager) {
return <span
key={manager.id}
>
{manager.name}
</span>;
}
function renderSelectedManager(manager) {
return <div className="d-inline-block">{manager.name}</div>;
}
function getChildren(item) {
return item.reports;
}
function getParent(item) {
return item.manager;
}
function getKey(item) {
return item.id;
}
function onSelectedItemChange(item: IManager) {
console.log(item.name);
}
class Example extends React.Component {
constructor(props) {
super(props);
this.state = {};
this.onSelectedItemChange = this.onSelectedItemChange.bind(this);
}
render() {
return (
<TreeViewSelect
style={{ width: "20rem" }}
defaultCollapsed={1}
renderSelectedItem={renderSelectedManager}
selectedItem={manager}
item={hierarchy.manager}
getChildren={getChildren}
getParent={getParent}
getKey={getKey}
renderItem={renderManagerLink}
onSelectedItemChange={onSelectedItemChange}
/>
);
}
}
| Prop | Type | Required | Description |
|---|---|---|---|
className | String | Set a class name for outer TreeViewSelect element. | |
style | Object | Sets a style for TreeViewSelect, can be useful to set a fixed width. | |
defaultCollapsed | Number | Use this to define what level should default to collapsed. Can be useful for big trees to keep just the first few levels open by default. | |
renderSelectedItem | Function | ✓ | How do we render the selected item. |
selectedItem | Object | ✓ | Currently selected item. |
item | Object | ✓ | Root node of the tree. |
getChildren | Function | ✓ | Used on a node to get the children. This allows a flexible data structure as input. |
getParent | Function | ✓ | Get parent for an item. This is used to make sure that selected items are not collapsed. |
getKey | Function | ✓ | Get the key for a node. Used for item equivalency as well as for React key. |
renderItem | Function | ✓ | Used to render an item in the treeview. |
onSelectedItemChange | Function | ✓ | Callback when the selected item changes. |
FAQs
A react based select control where the drop down is a tree view.
We found that react-treeviewselect demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.