-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.jsx
68 lines (56 loc) · 1.79 KB
/
App.jsx
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import React from 'react'
import { connect, Provider } from 'react-redux'
import { render } from 'react-dom';
import Content from './components/Content.jsx';
import AppReduxStore from './lib-redux/AppReduxStore'
import AppReduxActions from './lib-redux/AppReduxActions';
import List from './components/List.jsx'
const mapContentStateToProps = (state) => {
return {
text : 'A simple redux implmentation with react',
articles: state.articles,
articlesApproved: state.articlesApproved,
message: state.message,
}
}
const mapSubmittedStateToProps = (state) => {
return {
articles: state.articles,
listHeader: 'Submitted Articles',
}
}
const mapApprovalStateToProps = (state) => {
return {
articles: state.articlesApproved,
listHeader: 'Approved Articles',
}
}
const mapContentDispatchToProps = (dispatch) => {
return {
onSubmit: (value) => dispatch(AppReduxActions.submitArticle(value)),
onApprove:(value) => dispatch(AppReduxActions.approveArticle(value)),
onRemove: (key) => dispatch(AppReduxActions.removeArticle(key))
}
}
const mapListDispatchToProps = (dispatch) => {
return {
onRemove: (key) => dispatch(AppReduxActions.removeArticle(key))
}
}
const AppContainer = connect(mapContentStateToProps, mapContentDispatchToProps)(Content)
const AppListSubmitted = connect(mapSubmittedStateToProps, mapListDispatchToProps)(List)
const AppListApprovals = connect(mapApprovalStateToProps, mapListDispatchToProps)(List)
const Container = () => (
<div>
<AppContainer />
<AppListSubmitted />
<AppListApprovals/>
</div>
)
const App = () =>
<div>
<Provider store={AppReduxStore}>
<Container />
</Provider>
</div>
export default App;