To describe my issue I will start by showing the jsx markup:
<Selector>
<ItemCategory title="A Special Category">
<Item title="PDF File" file="/file.pdf" />
</ItemCategory>
<Item title="PDF File 2" file="/file2.pdf" />
</Selector>
Basically I have a list of PDFs I want to display. Items can belong to a category or not. In the Selector-Component I have the current selected PDF as a state. See my current Selector Component below.
export class Selector extends React.Component {
constructor(props) {
super(props);
this.state = {
currentSelection: null
};
}
render() {
var currentSelection = this.state.currentSelection || <NothingSelected />;
return (
<div className={"selector " + this.props.className}>
<div className="sidemenu">
<HeaderItem />
<div className="sidemenu-area">
{this.props.children}
</div>
</div>
<div className="selector-area">
{currentSelection}
</div>
</div>
);
}
}
Now I want if you click on an Item-Component to change the current selection to the clicked Item.
Any idea how I can add the onClick events?