Duplicate declaration "decorators"
When I tried to follow the instructors in the readme file to create custom decorators, I am getting this error. Can someone tell me the right approach as the one mentioned in the readme seems wrong!
Here is the code:
const decorators = { Header: (props) => { return ( <div style={props.style}> {props.node.name} </div> ); } }; class TreeExample extends React.Component { constructor(props){ super(props); this.state = {}; this.onToggle = this.onToggle.bind(this); } onToggle(node, toggled){ if(this.state.cursor){this.state.cursor.active = false;} node.active = true; if(node.children){ node.toggled = toggled; } this.setState({ cursor: node }); } render(){ return ( <Treebeard data={data} onToggle={this.onToggle} decorators={decorators} /> ); } }
No issue with the data, my data is a big json so, not sharing here.