So I have a sidenav
that has expansion panels that open. I'm setting the state
on which expansion panel is open. But on click of one of the sidenav
, I get redirected to the list item path and the sidenav
returns to original state
. on the redirect I'd like for the part of the sidenav
that was open to persist. I'm trying to do it like this. I'm not sure why it's not working.
handleOpen = path => {
this.setState({ openPath: path });
sessionStorage.setItem('path', this.state.openPath);
};
class Sidebar extends React.Component {
constructor(props){
super(props);
let getPath = JSON.parse(sessionStorage.getItem('path'))
this.state = {
openPath: getPath
};
}