mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-04-20 05:26:20 +00:00
Moved propTypes and defaultProps as static properties in class components
This commit is contained in:
@@ -9,12 +9,12 @@ import PropTypes from 'prop-types';
|
||||
import { resetSelectedServer } from '../servers/reducers/selectedServer';
|
||||
import './Home.scss';
|
||||
|
||||
const propTypes = {
|
||||
resetSelectedServer: PropTypes.func,
|
||||
servers: PropTypes.object,
|
||||
};
|
||||
|
||||
export class HomeComponent extends React.Component {
|
||||
static propTypes = {
|
||||
resetSelectedServer: PropTypes.func,
|
||||
servers: PropTypes.object,
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
this.props.resetSelectedServer();
|
||||
}
|
||||
@@ -51,8 +51,6 @@ export class HomeComponent extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
HomeComponent.propTypes = propTypes;
|
||||
|
||||
const Home = connect(pick([ 'servers' ]), { resetSelectedServer })(HomeComponent);
|
||||
|
||||
export default Home;
|
||||
|
||||
@@ -10,11 +10,11 @@ import ServersDropdown from '../servers/ServersDropdown';
|
||||
import './MainHeader.scss';
|
||||
import shlinkLogo from './shlink-logo-white.png';
|
||||
|
||||
const propTypes = {
|
||||
location: PropTypes.object,
|
||||
};
|
||||
|
||||
export class MainHeaderComponent extends React.Component {
|
||||
static propTypes = {
|
||||
location: PropTypes.object,
|
||||
};
|
||||
|
||||
state = { isOpen: false };
|
||||
handleToggle = () => {
|
||||
this.setState(({ isOpen }) => ({
|
||||
@@ -64,8 +64,6 @@ export class MainHeaderComponent extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
MainHeaderComponent.propTypes = propTypes;
|
||||
|
||||
const MainHeader = withRouter(MainHeaderComponent);
|
||||
|
||||
export default MainHeader;
|
||||
|
||||
@@ -17,14 +17,14 @@ import TagsList from '../tags/TagsList';
|
||||
import { serverType } from '../servers/prop-types';
|
||||
import AsideMenu from './AsideMenu';
|
||||
|
||||
const propTypes = {
|
||||
match: PropTypes.object,
|
||||
selectServer: PropTypes.func,
|
||||
location: PropTypes.object,
|
||||
selectedServer: serverType,
|
||||
};
|
||||
|
||||
export class MenuLayoutComponent extends React.Component {
|
||||
static propTypes = {
|
||||
match: PropTypes.object,
|
||||
selectServer: PropTypes.func,
|
||||
location: PropTypes.object,
|
||||
selectedServer: serverType,
|
||||
};
|
||||
|
||||
state = { showSideBar: false };
|
||||
|
||||
// FIXME Shouldn't use componentWillMount, but this code has to be run before children components are rendered
|
||||
@@ -105,8 +105,6 @@ export class MenuLayoutComponent extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
MenuLayoutComponent.propTypes = propTypes;
|
||||
|
||||
const MenuLayout = compose(
|
||||
connect(pick([ 'selectedServer', 'shortUrlsListParams' ]), { selectServer }),
|
||||
withRouter
|
||||
|
||||
@@ -2,18 +2,18 @@ import React from 'react';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
const propTypes = {
|
||||
location: PropTypes.object,
|
||||
window: PropTypes.shape({
|
||||
scrollTo: PropTypes.func,
|
||||
}),
|
||||
children: PropTypes.node,
|
||||
};
|
||||
const defaultProps = {
|
||||
window,
|
||||
};
|
||||
|
||||
export class ScrollToTopComponent extends React.Component {
|
||||
static propTypes = {
|
||||
location: PropTypes.object,
|
||||
window: PropTypes.shape({
|
||||
scrollTo: PropTypes.func,
|
||||
}),
|
||||
children: PropTypes.node,
|
||||
};
|
||||
static defaultProps = {
|
||||
window,
|
||||
};
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
const { location, window } = this.props;
|
||||
|
||||
@@ -27,9 +27,6 @@ export class ScrollToTopComponent extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
ScrollToTopComponent.defaultProps = defaultProps;
|
||||
ScrollToTopComponent.propTypes = propTypes;
|
||||
|
||||
const ScrollToTop = withRouter(ScrollToTopComponent);
|
||||
|
||||
export default ScrollToTop;
|
||||
|
||||
Reference in New Issue
Block a user