/
App.js
39 lines (35 loc) · 856 Bytes
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// @flow @jsx h
import {h, Component} from 'preact';
import {connect} from 'redux-zero/preact';
import actions from './Store/Actions';
import Banner from './components/Banner';
import Modal from './components/Modal';
type initProps = {
messages: Object,
locale: string,
};
export class App extends Component<initProps> {
translate = (string: string) => {
const {messages, locale} = this.props;
if (
messages === undefined ||
locale === undefined ||
messages[locale] === undefined
)
return string;
return messages[locale][string] || string;
};
render() {
return (
<div>
<Modal t={this.translate} />
<Banner t={this.translate} />
</div>
);
}
}
const mapToProps = ({locale, messages}) => ({locale, messages});
export default connect(
mapToProps,
actions,
)(App);