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

Question about code

nolatone opened this issue · comments

Given this function in CheckBoxTree.js:

` onCheck(nodeInfo) {
const { checkModel, noCascade, onCheck } = this.props;
const model = this.state.model.clone();
const node = model.getNode(nodeInfo.value);

    model.toggleChecked(nodeInfo, nodeInfo.checked, checkModel, noCascade);
    onCheck(model.serializeList('checked'), { ...node, ...nodeInfo });
}`

In the line:
onCheck(model.serializeList('checked'), { ...node, ...nodeInfo });

What is the second argument to onCheck for? This part: { ...node, ...nodeInfo }

I'm not seeing that it does anything. The onCheck only takes the list of nodes returned by model.serializeList().

The component supplies the second parameter in case the developer wants to know which node triggered this change. This was a feature request I received some time back.