Skip to content

Commit 1eb91a8

Browse files
author
Joao Moura
committed
Added static cloner
1 parent 205398d commit 1eb91a8

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-multi-lang",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "React Multilanguage Higher-Order Component",
55
"main": "lib/index.js",
66
"files": [
@@ -42,6 +42,7 @@
4242
"flow-copy-source": "^1.2.1"
4343
},
4444
"dependencies": {
45+
"hoist-non-react-statics": "^2.3.1",
4546
"react-native-uuid": "^1.4.9"
4647
}
4748
}

src/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import * as React from 'react'
44
import uuid from 'react-native-uuid'
55

6+
// statics handler
7+
import hoistStatics from 'hoist-non-react-statics'
8+
69
let language: string = 'pt'
710
let subscribes: {
811
cb: () => mixed,
@@ -52,7 +55,7 @@ export function setLanguage (lang: string) {
5255
}
5356

5457
export function translate (Component: React$ComponentType<*>):React$ComponentType<*> {
55-
return class extends React.Component<{}, *> {
58+
class TranslatedComponet extends React.Component<{}, *> {
5659
id: string
5760

5861
componentDidMount () {
@@ -71,6 +74,8 @@ export function translate (Component: React$ComponentType<*>):React$ComponentTyp
7174
)
7275
}
7376
}
77+
78+
return hoistStatics(TranslatedComponet, Component)
7479
}
7580

7681
export default {

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,10 @@ [email protected]:
12831283
version "2.16.3"
12841284
resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed"
12851285

1286+
hoist-non-react-statics@^2.3.1:
1287+
version "2.3.1"
1288+
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.3.1.tgz#343db84c6018c650778898240135a1420ee22ce0"
1289+
12861290
home-or-tmp@^2.0.0:
12871291
version "2.0.0"
12881292
resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8"

0 commit comments

Comments
 (0)