jakezatecky/react-checkbox-tree

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

bollampallyrohit opened this issue · 1 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]);
}