Skip to content

Commit

Permalink
Merge 39e9468 into 4276370
Browse files Browse the repository at this point in the history
  • Loading branch information
ahoseinian committed Dec 5, 2017
2 parents 4276370 + 39e9468 commit ec75d05
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/context.js
Expand Up @@ -4,7 +4,8 @@ let defaultOptions = {
bindI18n: 'languageChanged loaded',
bindStore: 'added removed',
translateFuncName: 't',
nsMode: 'default'
nsMode: 'default',
usePureComponent: false,
};

let i18n;
Expand Down
10 changes: 10 additions & 0 deletions src/translate.js
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import hoistStatics from 'hoist-non-react-statics';
import { getDefaults, setDefaults, getI18n, setI18n } from './context';
import I18n from './I18n';
import shallowEqual from 'fbjs/lib/shallowEqual';

function getDisplayName(component) {
return component.displayName || component.name || 'Component';
Expand All @@ -25,6 +26,15 @@ export default function translate(namespaces, options = {}) {

this.getWrappedInstance = this.getWrappedInstance.bind(this);
}


shouldComponentUpdate(nextProps){
if(!this.options.usePureComponent){
return true
}

return !shallowEqual(this.props, nextProps);
}

getWrappedInstance() {
if (!this.options.withRef) {
Expand Down

0 comments on commit ec75d05

Please sign in to comment.