-
Notifications
You must be signed in to change notification settings - Fork 1
/
image 1
84 lines (53 loc) · 1.82 KB
/
image 1
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
``
Store meal {
Break Fast: chai papa
Lunch : dal chawal
Dinner: spicy tende
}
Provider{
}
Container{
HR
Operations
QA
}
component{
Team A
Team B
Team C
}
import providers and connect with Store
make Priver Parent of Router
use store as attribute of provider and pass store to it
create store folder and make index.js for creating store
import reducer from your reducer file
import createStore and applyMiddleWare from library redux
import thunk from redux-thunk
use createStore method and pass reducer, {} and applyMiddleWare(thunk) in param
create reducer folder inside store folder
create index.js and reducer.js inside reducer folder
import all reducers
import combine reducer from library redux
use combineReducer method and pass all reducers in Object form
initialize all states
create reducer function and pass states and action as param
use switch and check action.type in all cases
if case matches then return ...state and if any changes there in form of object
To Connect with States and Actions in Component or Container
import connect from react-redux
call connect at the end with two functions in params and call again with componentName in param
function mapStateToProp(state){
return({
userName: state.root.userName
})
}
import name of actionFunction
function mapDispatchToProp(dispatch){
return({
changeUserName: ()=>{dispatch(changeUserName())}
})
}
Action file
export function to dispatch action Object
Const file
Object with action types