I am trying to get items to be visible/invisible based on an onclick function being called however I am getting "Unhandled Rejection (TypeError): Cannot read property 'style' of null"
My code reads as follows:
<div>
{output.map((group) => (
<div className="sidebar">
<div className="groupbutton" onClick={item_open({group})}>{group}</div>
<div>
{this.state.items.filter(item => item.GroupDesc === group).map((items) => (
<div className="itembutton" style={{display:'none'}} id={group}>{items.TypeDesc}</div>))}
</div>
</div>))}
</div>
with a function
function item_open(group) {
document.getElementById(group).style.display = "block";
}
I believe these should:
-give all items in the group an id of the group name
-the function should call all of those items with getElementById
-they should then all get the display: "block" attribute
Can anyone see why this might not work?