Skip to content

Commit

Permalink
Translation function now doenst trigger unexpected renders
Browse files Browse the repository at this point in the history
  • Loading branch information
JWebCoder committed May 17, 2018
1 parent 85ca5a6 commit e35b8e9
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 13 deletions.
1 change: 0 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"dependencies": {
"react": "^16.1.1",
"react-dom": "^16.1.1",
"react-multi-lang": "^1.0.0",
"react-scripts": "1.0.17"
},
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion example/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class App extends React.Component {
setLanguage(lang)
}
render () {
console.log(getLanguage())
return (
<div className="App">
<header className="App-header">
Expand All @@ -20,6 +19,8 @@ class App extends React.Component {
<p className="App-intro">
To change language just press the buttons beneath
</p>
<div>Selected lang <b>{getLanguage()}</b></div>
<br/>
<button onClick={() => this.changeLang('pt')}>PT</button>
<button onClick={() => this.changeLang('en')}>EN</button>
</div>
Expand Down
10 changes: 0 additions & 10 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2935,10 +2935,6 @@ [email protected]:
version "4.2.0"
resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.0.tgz#72d9d0754f7fe25ca2d01ad8f8f9a9449a89526d"

hoist-non-react-statics@^2.3.1:
version "2.5.0"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.5.0.tgz#d2ca2dfc19c5a91c5a6615ce8e564ef0347e2a40"

home-or-tmp@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8"
Expand Down Expand Up @@ -5131,12 +5127,6 @@ react-error-overlay@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-3.0.0.tgz#c2bc8f4d91f1375b3dad6d75265d51cd5eeaf655"

react-multi-lang@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/react-multi-lang/-/react-multi-lang-1.0.0.tgz#0e328d5b3a357f5c6203dd8f0323cceda216ccfd"
dependencies:
hoist-non-react-statics "^2.3.1"

[email protected]:
version "1.0.17"
resolved "https://registry.yarnpkg.com/react-scripts/-/react-scripts-1.0.17.tgz#c30029123b561a060227af4d7797d50a222d3fbf"
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export function translate (Component: React$ComponentType<*>): React$ComponentTy

render () {
return (
<Component {...this.props} t={(key: string, args?:{[string]: string}): string => t(key, args)}/>
<Component {...this.props} t={t}/>
)
}
}
Expand Down

0 comments on commit e35b8e9

Please sign in to comment.