Is there a method that can be called in componentDidMount() and componentDidUpdate() to activate the menu? #56
Description
I have AdminLTE running in ReactJS but I was wondering there is a method out there for setting the parent li to .active based on the child also being .active? Achieving .active on the is easy with Navlink but setting the parent class is trickier. We would also need to have li.treeview set to li.treeview.menu-open if it has active children too. I have put together the following in jQuery and put it in componentDidMount() and componentDidUpdate() but for some reason the code is not run in those lifecycle events (I suspect it has something to do with not using refs: -
$('ul.sidebar-menu li:not(.treeview):has(a.active)').addClass('active');
The following sets the li.treeview classes by event triggering: -
$('ul.sidebar-menu li.treeview:not(.menu-open)').has('a.active').find('a').trigger( "click" );
As with the code above, this too works but is not being called properly in the lifecycle events. Although is should be pointed out that the second piece of code is doing .trigger("click") on all li.treeview nodes, regardless of whether or they have children with a.active (i.e. in multiple nested menus).
Any help/thoughts/advice?