Skip to content

Commit

Permalink
Merge pull request #243 from tomegz/improvement/class-properties
Browse files Browse the repository at this point in the history
Improvement: Utilize @babel/plugin-proposal-class-properties by using…
  • Loading branch information
patw0929 authored Dec 16, 2018
2 parents 50992a8 + f5ac576 commit 49cb852
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 101 deletions.
16 changes: 4 additions & 12 deletions src/components/CountryList.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ export default class CountryList extends Component {
isMobile: PropTypes.bool,
};

constructor() {
super();
this.handleMouseOver = this.handleMouseOver.bind(this);
this.setFlag = this.setFlag.bind(this);
this.appendListItem = this.appendListItem.bind(this);
this.setDropdownPosition = this.setDropdownPosition.bind(this);
}

shouldComponentUpdate(nextProps) {
const shouldUpdate = !utils.shallowEquals(this.props, nextProps);

Expand All @@ -39,7 +31,7 @@ export default class CountryList extends Component {
return shouldUpdate;
}

setDropdownPosition() {
setDropdownPosition = () => {
utils.removeClass(this.listElement, 'hide');

const inputTop = this.props.inputTop;
Expand Down Expand Up @@ -72,11 +64,11 @@ export default class CountryList extends Component {
this.listElement.setAttribute('class', 'country-list');
}

setFlag(iso2) {
setFlag = (iso2) => {
this.props.setFlag(iso2);
}

appendListItem(countries, isPreferred = false) {
appendListItem = (countries, isPreferred = false) => {
const preferredCountriesCount = this.props.preferredCountries.length;

return countries.map((country, index) => {
Expand Down Expand Up @@ -122,7 +114,7 @@ export default class CountryList extends Component {
});
}

handleMouseOver(e) {
handleMouseOver = (e) => {
if (e.currentTarget.getAttribute('class').indexOf('country') > -1) {
const selectedIndex = utils.retrieveLiIndex(e.currentTarget);

Expand Down
Loading

0 comments on commit 49cb852

Please sign in to comment.