Reputation: 1503
I am trying to set I18n.t to a variable then call this variable inside my class. But I am getting TypeError: undefined is not an object.
import I18n from 'react-native-i18n';
let tt = I18n.t;
class App extends Component {
render(){
return (
<View>
<Text>{tt('greeting')}</Text>
</View>
)
}
}
Upvotes: 0
Views: 485
Reputation: 171
This will be useful check it out:
var tt = (translation) => I18n.t(translation);
<Text>{tt('greeting')}</Text>
Upvotes: 2