Skip to content

Commit

Permalink
Merge pull request #150 from RenaldLaranjeira/master
Browse files Browse the repository at this point in the history
Handle i18next added and removed resource events.
  • Loading branch information
jamuhl authored Jul 5, 2016
2 parents 1f6f814 + 147d921 commit e99ac4b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ npm-debug.log.*
# Ignore various temporary files
*~
*.swp
.idea/


# Ignore various Node.js related directories and files
Expand Down
3 changes: 3 additions & 0 deletions react-i18next.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
_this2.setState({ ready: true });
});
this.i18n.on('languageChanged loaded', this.onI18nChanged);
this.i18n.store.on('added removed', this.onI18nChanged);
}
}, {
key: 'componentWillUnmount',
Expand All @@ -176,6 +177,8 @@
if (this.onI18nChanged) {
this.i18n.off('languageChanged', this.onI18nChanged);
this.i18n.off('loaded', this.onI18nChanged);
this.i18n.store.off('added', this.onI18nChanged);
this.i18n.store.off('removed', this.onI18nChanged);
}
}
}, {
Expand Down
2 changes: 1 addition & 1 deletion react-i18next.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ export default function translate(namespaces, options = {}) {
this.setState({ ready: true });
});
this.i18n.on('languageChanged loaded', this.onI18nChanged);
this.i18n.store.on('added removed', this.onI18nChanged);
}

componentWillUnmount() {
this.mounted = false;
if (this.onI18nChanged) {
this.i18n.off('languageChanged', this.onI18nChanged);
this.i18n.off('loaded', this.onI18nChanged);
this.i18n.store.off('added', this.onI18nChanged);
this.i18n.store.off('removed', this.onI18nChanged);
}
}

Expand Down

0 comments on commit e99ac4b

Please sign in to comment.