1+ import * as React from 'react'
2+ import { Row , Col , Button , Badge , Icon , Form , Input , Select } from 'antd'
3+ import { ReduxProvider , connect } from '@plugins/react-redux'
4+ import { store } from './reducer'
5+
6+ console . log ( store . getState ( ) , '---store' )
7+
8+ const FormItem = Form . Item
9+ const TextArea = Input . TextArea
10+ const Option = Select . Option
11+
12+ const styles = {
13+ block : {
14+ marginBottom : '20px' ,
15+ boxShadow : 'rgba(0, 0, 0, 0.12) 0px 1px 6px, rgba(0, 0, 0, 0.12) 0px 1px 4px' ,
16+ padding : '10px'
17+ } ,
18+ flex : {
19+ display : 'flex' ,
20+ alignItems : 'center'
21+ } ,
22+ padding : {
23+ padding : '10px 0'
24+ }
25+ }
26+
27+
28+ export default class DemoRedux extends React . Component < IProps > {
29+
30+
31+ add = ( ) => {
32+ store . dispatch ( { type : 'ADD' } )
33+ }
34+ dec = ( ) => {
35+ store . dispatch ( { type : 'DECREASE' } )
36+ }
37+
38+ shouldComponentUpdate ( preState : any , nextProps : any ) {
39+ console . log ( preState , nextProps )
40+ return false
41+ }
42+
43+ componentDidMount ( ) {
44+ console . log ( this , 'store.getState().counter' )
45+ }
46+
47+ render ( ) {
48+ // const count = 9
49+ const { count } = store . getState ( ) . counter
50+ console . log ( count , ' =-===count ' )
51+
52+ return < ReduxProvider store = { store } >
53+ < div >
54+ < section style = { styles . block } >
55+ < h3 > redux测试</ h3 >
56+ < Row style = { styles . padding } >
57+ < Col span = { 24 } >
58+ < Button onClick = { this . dec } >
59+ < Icon type = "minus" />
60+ </ Button >
61+ < Badge count = { count } showZero = { true } />
62+ < Button onClick = { this . add } >
63+ < Icon type = "plus" />
64+ </ Button >
65+ </ Col >
66+ </ Row >
67+ </ section >
68+ </ div >
69+ </ ReduxProvider >
70+ }
71+ }
0 commit comments