Skip to content
Snippets Groups Projects
Unverified Commit a119c96d authored by Paul Kaplan's avatar Paul Kaplan Committed by GitHub
Browse files

Merge pull request #3594 from paulkaplan/too-many-renders

Fix a couple areas where we are rendering too much
parents 8e28ebbe 9dc453bb
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@ class LanguageSelector extends React.Component {
}
handleChange (e) {
const newLocale = e.target.value;
if (this.props.supportedLocales.includes(newLocale)) {
if (this.props.messagesByLocale[newLocale]) {
this.props.onChangeLanguage(newLocale);
document.documentElement.lang = newLocale;
}
......@@ -25,7 +25,7 @@ class LanguageSelector extends React.Component {
render () {
const {
onChangeLanguage, // eslint-disable-line no-unused-vars
supportedLocales, // eslint-disable-line no-unused-vars
messagesByLocale, // eslint-disable-line no-unused-vars
children,
...props
} = this.props;
......@@ -43,13 +43,14 @@ class LanguageSelector extends React.Component {
LanguageSelector.propTypes = {
children: PropTypes.node,
currentLocale: PropTypes.string.isRequired,
onChangeLanguage: PropTypes.func.isRequired,
supportedLocales: PropTypes.arrayOf(PropTypes.string)
// Only checking key presence for messagesByLocale, no need to be more specific than object
messagesByLocale: PropTypes.object, // eslint-disable-line react/forbid-prop-types
onChangeLanguage: PropTypes.func.isRequired
};
const mapStateToProps = state => ({
currentLocale: state.locales.locale,
supportedLocales: Object.keys(state.locales.messagesByLocale)
messagesByLocale: state.locales.messagesByLocale
});
const mapDispatchToProps = dispatch => ({
......
......@@ -55,13 +55,15 @@ class SpriteSelectorItem extends React.Component {
window.removeEventListener('mousemove', this.handleMouseMove);
window.removeEventListener('touchend', this.handleMouseUp);
window.removeEventListener('touchmove', this.handleMouseMove);
this.props.onDrag({
img: null,
currentOffset: null,
dragging: false,
dragType: null,
index: null
});
if (this.props.dragging) {
this.props.onDrag({
img: null,
currentOffset: null,
dragging: false,
dragType: null,
index: null
});
}
setTimeout(() => {
this.noClick = false;
});
......@@ -156,6 +158,7 @@ SpriteSelectorItem.propTypes = {
body: PropTypes.string
}),
dragType: PropTypes.string,
dragging: PropTypes.bool,
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
index: PropTypes.number,
name: PropTypes.string,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment