I'm trying to use it without a local state.
const regions = this.props.regionsTree.regions; // redux store
const tree = {
category: 'sub_regions', // name of the property containing the children
selection: [],
model: regions, // object for iterate
display: (_) => _.region, // field for show
onSelect: (newSelection, item, ancestors, neighbours) => {
// newSelection -> updated array containing all the selected items
// item -> the newly selected item (excluding the old one in case of multi selection)
// ancestors -> the ancestors of the newly selected item
// neighbours -> the neighbours of the newly selected item
this.selection = newSelection;
},
};
/* Drag'n'drop presets */
const dragndrop = {
// To drag or drop on specific items
// you can use a function : (item) => true/false
draggable: true,
droppable: true,
drag: null, // action to perform on drag
drop: null, // action to perform on drop
over: null, // hook on dragover
enter: null, // hook on dragenter
leave: null, // hook on dragleave
cancel: null, // action to perform on cancellation
guard: null, // prevents dragover and drop
};
<TreeView
{...tree}
dragndrop={dragndrop}
onSelect={tree.onSelect}
/>
Of course, drag'n'drop don't work (need describe action).