Skip to content

Commit 3e7a2b2

Browse files
authored
Merge pull request #10 from streamich/fix-provider
feat: 🎸 allow to change locale through props
2 parents ec9c8d0 + 31e91b5 commit 3e7a2b2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/createTranslations.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ export const createTranslations = (ns: string = 'main'): Result => {
4242
}
4343
}
4444

45+
shouldComponentUpdate (nextProps) {
46+
if (nextProps.locale !== this.props.locale) {
47+
this.setLocale(nextProps.locale);
48+
}
49+
return true;
50+
};
51+
4552
load = async (locale: string, ns: string) => {
4653
if (!this.state.map[locale]) {
4754
this.state.map[locale] = {};

0 commit comments

Comments
 (0)