mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-10 18:27:25 +03:00
Ensured toggle menu is hidden on route change
This commit is contained in:
parent
ec6b11d9c9
commit
ca4365d820
1 changed files with 14 additions and 6 deletions
|
@ -1,20 +1,26 @@
|
||||||
import plusIcon from '@fortawesome/fontawesome-free-solid/faPlus';
|
import plusIcon from '@fortawesome/fontawesome-free-solid/faPlus';
|
||||||
import FontAwesomeIcon from '@fortawesome/react-fontawesome';
|
import FontAwesomeIcon from '@fortawesome/react-fontawesome';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link, withRouter } from 'react-router-dom'
|
||||||
import { Collapse, Nav, Navbar, NavbarBrand, NavbarToggler, NavItem, NavLink } from 'reactstrap';
|
import { Collapse, Nav, Navbar, NavbarBrand, NavbarToggler, NavItem, NavLink } from 'reactstrap';
|
||||||
import ServersDropdown from '../servers/ServersDropdown';
|
import ServersDropdown from '../servers/ServersDropdown';
|
||||||
import './MainHeader.scss';
|
import './MainHeader.scss';
|
||||||
import shlinkLogo from './shlink-logo-white.png';
|
import shlinkLogo from './shlink-logo-white.png';
|
||||||
|
|
||||||
export default class MainHeader extends React.Component {
|
export class MainHeader extends React.Component {
|
||||||
state = { isOpen: false };
|
state = { isOpen: false };
|
||||||
toggle = () => {
|
toggle = () => {
|
||||||
this.setState({
|
this.setState(({ isOpen }) => ({
|
||||||
isOpen: !this.state.isOpen
|
isOpen: !isOpen
|
||||||
});
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps) {
|
||||||
|
if (this.props.location !== prevProps.location) {
|
||||||
|
this.setState({ isOpen: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Navbar color="primary" dark fixed="top" className="main-header" expand="md">
|
<Navbar color="primary" dark fixed="top" className="main-header" expand="md">
|
||||||
|
@ -36,3 +42,5 @@ export default class MainHeader extends React.Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default withRouter(MainHeader);
|
||||||
|
|
Loading…
Reference in a new issue