Skip to content

Commit

Permalink
remove redundant state
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Jun 11, 2017
1 parent e668971 commit 8f1ccba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
17 changes: 5 additions & 12 deletions src/pagination/PaginationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ class PaginationList extends Component {
constructor(props) {
super(props);
this.state = {
open: this.props.open,
show: this.props.show
open: this.props.open
};
}

componentWillReceiveProps() {
const { keepSizePerPageState } = this.props;
if (!keepSizePerPageState) {
this.setState({
open: false,
show: false
open: false
});
}
}
Expand Down Expand Up @@ -51,8 +49,7 @@ class PaginationList extends Component {

if (keepSizePerPageState) {
this.setState({
open: false,
show: false
open: false
});
}

Expand All @@ -74,15 +71,13 @@ class PaginationList extends Component {
}
}
this.setState({
open: false,
show: false
open: false
});
}

toggleDropDown = () => {
this.setState({
open: !this.state.open,
show: !this.state.show
open: !this.state.open
});
}

Expand Down Expand Up @@ -162,7 +157,6 @@ class PaginationList extends Component {
if (sizePerPageDropDown) {
dropdown = sizePerPageDropDown({
open: this.state.open,
show: this.state.show,
hideSizePerPage,
currSizePerPage: String(sizePerPage),
sizePerPageList,
Expand Down Expand Up @@ -196,7 +190,6 @@ class PaginationList extends Component {
dropdown = (
<SizePerPageDropDown
open={ this.state.open }
show={ this.state.show }
hidden={ hideSizePerPage }
currSizePerPage={ String(sizePerPageText) }
options={ sizePerPageOptions }
Expand Down
7 changes: 2 additions & 5 deletions src/pagination/SizePerPageDropDown.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class SizePerPageDropDown extends Component {
render() {
const {
open,
show,
hidden,
onClick,
options,
Expand All @@ -17,13 +16,12 @@ class SizePerPageDropDown extends Component {
currSizePerPage
} = this.props;

const openClass = open ? 'open' : '';
const showClass = show ? 'show' : '';
const openClass = open ? 'open show' : '';
const dropDownStyle = { visibility: hidden ? 'hidden' : 'visible' };

return (
<span style={ dropDownStyle }
className={ `${variation} ${openClass} ${showClass} ${className} ${sizePerPageDefaultClass}` }>
className={ `${variation} ${openClass} ${className} ${sizePerPageDefaultClass}` }>
<button className={ `btn ${btnContextual} dropdown-toggle` }
id='pageDropDown' data-toggle='dropdown'
aria-expanded={ open }
Expand Down Expand Up @@ -54,7 +52,6 @@ SizePerPageDropDown.propTypes = {
};
SizePerPageDropDown.defaultProps = {
open: false,
show: false,
hidden: false,
btnContextual: 'btn-default',
variation: 'dropdown',
Expand Down

0 comments on commit 8f1ccba

Please sign in to comment.