I'm making a custom Tree using Ant Design.
I have a treeData with color property, I made an array of treeNode ref by binding ref of that treeNode into treeNodeRef
<TreeNode ref={(ref) => (treeNodeRef.current[key] = ref)}>
then iterate treeNodeRef to change style of that treeNode like this:
useEffect(() => {
treeNodeRef.current.forEach((element, index) => {
element.style.backgroundColor = treeRef.state.treeData[index].color;
console.log(element);
});
}, [treeNodeRef, treeRef]);
But my treeNode.current always empty, what is wrong?
Can I change treeNode in this way?
Each TreeNode component has a checkbox, so how can change the style of that checkbox?
This is my code: https://codesandbox.io/s/controlled-tree-antd4100-forked-e29pk