jakezatecky / react-checkbox-tree

A simple and elegant checkbox tree for React.

Home Page:https://jakezatecky.github.io/react-checkbox-tree/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When a parent is checked is it possible to expand all its children nodes

bollampallyrohit opened this issue · comments

Hello,

In our project we want to have a functionality where in when a parent with children is checked then expand all its children. So is it possible to do it

There is no property to enable this behavior, but it is possible to code this yourself by setting the state of the expanded property within the onCheck function, by utilizing the second parameter:

const [checked, setChecked] = useState([]);
const [expanded, setExpanded] = useState([]);

function onCheck(checked, node) {
  setChecked(checked);
  setExpanded([...expanded, node.value]);
}