Skip to content

Commit

Permalink
fix for rendering from root
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Whitton committed Jan 17, 2018
1 parent 543aa67 commit acc8f38
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/js/components/translate-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ const ABBREVIATED_OPTIONS = {
export default class TranslateDropdown extends connect()(Component) {

componentWillReceiveProps(nextProps) {
if (this.props.small !== nextProps.small) {
this.updateForSize(nextProps);
if (this.props.small !== nextProps.small ||
this.state.selected.value !== nextProps.selected) {
this.update(nextProps);
}
}
componentWillMount() {
this.updateForSize(this.props);
this.update(this.props);
}

updateForSize({ small }) {
update({ small, selected }) {
if (small) {
let { value, label } = ABBREVIATED_OPTIONS[this.props.selected] || {};
let { value, label } = ABBREVIATED_OPTIONS[selected] || {};
this.setState({
selected: {
value: value,
Expand All @@ -48,7 +49,7 @@ export default class TranslateDropdown extends connect()(Component) {
options: [ABBREVIATED_OPTIONS.fr, ABBREVIATED_OPTIONS.en]
});
} else {
let { value, label } = OPTIONS[this.props.selected] || {};
let { value, label } = OPTIONS[selected] || {};
this.setState({
selected: {
value: value,
Expand Down

0 comments on commit acc8f38

Please sign in to comment.